Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How do display error messages instantly when command fails?

Answer Posted / ajit mohan b

Suppose you are trying to cat a non existing file:

cat /etc/shado 2>/dev/null || echo “Failed to open file”

command 2 "echo" is executed only if command 1 "cat" returns
a non-zero exit status

# cat /etc/shado 2>/dev/null || echo "Failed to open file"
Failed to open file
#

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I clear my run history?

1070


What is mkdir p linux?

1057


What does (cd dir && command) do?

986


What is difference between sh and bash?

991


What is FC command?

865


How often do you use grep command and how in Linux operating system?

1112


Why we use pwd command in linux?

1071


How do I check my system performance?

1017


What are linux commands useful?

1055


If the programmer wishes to execute an instruction at the specified time. Which command is used?

1418


Which command will show you free/used memory?

992


what is the roles and responsibilities in linux system admin having 2yrs exp..?

4190


Suppose I lost a root password and I need to give it, I treid to change it through single usermode even though I am not get a password, then what is the otherprocedure to give a root password?

961


How many types of commands are there in linux?

1053


What is phony in makefile?

1006