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
What does rmdir do in linux?
What is mask and umask in linux?
How do you create a blank file in linux?
What command would you use to check how much memory is being used by linux?
How do you insert comments in the command line prompt?
What file type is a makefile?
Brief about FTP hostname?
What is p command?
You locate a command in the /bin directory but do not know what it does. What command can you use to determine its purpose
What is bash command?
How you will create new folder / directories and how to remove file and folder in linux?
What is cpu in linux?
What is sudo bash command?
How to recover /etc/passwd file and /etc/shadow file?
How do I do a whois search?