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

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

1159


Explain about refer?

989


What is ulimit command?

1087


What does history command do in linux?

1197


What are the command prompt commands?

1076


Why is it called bash?

922


What does uname do in linux?

1117


What are the basic commands in command prompt?

1135


How does grep work in linux?

942


State and explain about features of UNIX?

1061


How do I list all processes in linux?

992


How can we increase disk read performance in single command in Linux?

991


Which command will show you free/used memory? Does free memory exist on linux?

1030


What does the ps command do in linux?

1042


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

1427