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 used for showing user info like Login Name, Canonical Name, Home Directory,Shell etc..?
Explain about refer?
What is ulimit command?
What does history command do in linux?
What are the command prompt commands?
Why is it called bash?
What does uname do in linux?
What are the basic commands in command prompt?
How does grep work in linux?
State and explain about features of UNIX?
How do I list all processes in linux?
How can we increase disk read performance in single command in Linux?
Which command will show you free/used memory? Does free memory exist on linux?
What does the ps command do in linux?
If the programmer wishes to execute an instruction at the specified time. Which command is used?