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

Which command is used to review boot messages?

0 Answers  


What is nbtstat command?

0 Answers  


What does in makefile do?

0 Answers  


How do I check my cpu speed?

0 Answers  


Explain trap command of linux?

0 Answers  






If the programmer wishes to execute an instruction at the specified time. Which command is used?

0 Answers  


1. Why "d" is postfix in almost every service name of Linux like httpd, dhcpd? 2. how to restrict su & ssh services for some users? 3. how can we configure a default gateway for 10 n/w cards in a server?

6 Answers  


What does comm do and how to use it?

0 Answers  


What is history command in linux?

0 Answers  


Why is it called bash?

0 Answers  


What is the copy command in linux?

0 Answers  


What is make command in linux?

0 Answers  


Categories