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 file and example?
How cp command works in linux?
What is the role of case sensitivity in affecting the way commands are used?
How do I check command history?
what is snmp and for what purpose we are using in linux
In Linux how you set time a limit on quota?
What is df command in unix?
What file type is a makefile?
Explain the linux ‘cd’ command options along with the description?
How can you copy lines into the buffer in command mode?
in unix how to change old name to new name
difference between Tcp and udp