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 |
Hi guys, I am working in MNC from 1 and half year as Software Engg but not in programming, its in Information Security. Now I am doing RHEL 5(Red Hat certification) to move into Linux Admin. Can anyone please give me the future scope of this field and please send me the interview questions or links to get the idea. Thanks, Sushant.
Can I delete .bash history?
Difference between swap partition and swap file?
Which of the Commands delete the files from the /tmp directory, issued by non-root user?
What is pwd in linux command?
What is simple command?
Which two commands can you use to delete directories?
What does the command env do?
What are the commands in linux?
You wish to print a file ‘draft’ with 60 lines on a page. What command would you use?
How do I do a whois search?
Who linux commands?