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 does rmdir do in linux?

1020


What is mask and umask in linux?

1055


How do you create a blank file in linux?

1057


What command would you use to check how much memory is being used by linux?

1079


How do you insert comments in the command line prompt?

1223


What file type is a makefile?

990


Brief about FTP hostname?

1145


What is p command?

1156


You locate a command in the /bin directory but do not know what it does. What command can you use to determine its purpose

1091


What is bash command?

1076


How you will create new folder / directories and how to remove file and folder in linux?

966


What is cpu in linux?

1107


What is sudo bash command?

1082


How to recover /etc/passwd file and /etc/shadow file?

1029


How do I do a whois search?

987