How do display error messages instantly when command fails?
Answers were Sorted based on User's Feedback
Answer / rallapalli
HE did not ask how to redirect error of a command. He said
clearly. How do you display error message instantly when
command fails.
ans:
By default it will display no need to do any thing. when u
type wrong command the error will display on screen.
Ex:
#usradd tom
ERR: command not found
ok?
| Is This Answer Correct ? | 7 Yes | 0 No |
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 |
What is difference between sh and bash?
When and how linux developed?
Why we use pwd command in linux?
What is Syntax of any Linux command?
What is the command to see on which port which service is running? And what is the difference between /etc/services file and net stat command?
how do you configure linux system as a router?
What does && mean in bash?
what command would you use to find the hostname of the server if yo ony have the ip address?
how to create SAMBA server in fedora 9 linux ?
Explain about refer?
what is snmp and for what purpose we are using in linux
What is mask and umask in linux?