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 command do you type to find help about the command who?
What is tail command in linux?
What is a good processor speed?
What does chmod 644 do?
What is mkdir p linux?
You have a tab delimited file called phonenos and want to change each tab to four spaces. What command can you use to accomplish this?
What is makefile in unix?
What are two functions the move mv command can carry out?
How often do you use grep command and how in Linux operating system?
How use linux command line?
Which command is used to find what is in your home directory?
Enlist some linux to file content commands?
What is a ulimit in unix?
why context switching time should be minimum? How it depends on hardware support?
What is the purpose output of cd command?