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

what is the command to uninstall processes in linux?

17 Answers   Aegon, HCL, IBM, Ugam Solutions,


what is linux utilities and editor

4 Answers   Oracle, Wipro,


What does kill in linux?

0 Answers  


How do I check cpu usage?

0 Answers  


What is bc command in unix?

0 Answers  






what is "ls* " is run options are 1) x 2).x 3) hidden 4) no disply tell exact answer.

6 Answers   Google,


What is a ulimit in unix?

0 Answers  


How do you insert comments in the command line prompt?

0 Answers  


You have a computer with 80 GB hard disk and Ubuntu 8.04 is installed on entire hard disk. Now you have to create a seprate partition for Windows OS and Install Win Xp as Dual boot. write down the steps involed along with the commands.

8 Answers   Bhel, Indian Navy, Tata Steel Limited,


How can we increase disk read performance in single command in Linux?

0 Answers  


How do I navigate in cmd?

0 Answers  


Who is unix command?

0 Answers  


Categories