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 |
How do I stress test my cpu?
How do you create a text file in linux terminal?
How will you execute a java program inside a kornshell script?
who invented unix?
Which priority has the process?how do u view?
How will retrieves incoming mails from different web sites
what is the fastest way to enter a series of commands from the command-line in linux
Which command is used to delete a group?
What does umask 022 mean?
How do I do a whois search?
What is file and example?
Which of the following tasks cannot be accomplished with the touch command?