How do display error messages instantly when command fails?

Answers were Sorted based on User's Feedback



How do display error messages instantly when command fails?..

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

How do display error messages instantly when command fails?..

Answer / 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

More Linux Commands Interview Questions

How do I stress test my cpu?

0 Answers  


How do you create a text file in linux terminal?

0 Answers  


How will you execute a java program inside a kornshell script?

1 Answers   HP,


who invented unix?

3 Answers   Wipro,


Which priority has the process?how do u view?

3 Answers   Yahoo,






How will retrieves incoming mails from different web sites

2 Answers   HCL, HP,


what is the fastest way to enter a series of commands from the command-line in linux

0 Answers  


Which command is used to delete a group?

0 Answers  


What does umask 022 mean?

0 Answers  


How do I do a whois search?

0 Answers  


What is file and example?

0 Answers  


Which of the following tasks cannot be accomplished with the touch command?

0 Answers  


Categories