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 stop a linux job?

981


What are commands in grammar?

1053


Is cmake a compiler?

1028


What are the commands used in command prompt?

981


What is $@ in shell?

947


What command would you use to create an empty file without opening it to edit it?

1006


Who is unix command?

1009


What are bash scripts used for?

1067


What does grep command do?

1009


What does mkdir mean in linux?

1102


What is difference between egrep and grep?

921


What is difference between sh and bash?

982


In order to display the last five commands you have entered using the fc command, you would type?

917


What command used for showing user info like Login Name, Canonical Name, Home Directory,Shell etc..?

1145


Which commands are used to set a processor-intensive job to use less cpu time?

1028