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 cmake in linux?

0 Answers  


What command you execute to display the last five commands you have entered?

4 Answers  


Which command is used to clear the screen?

0 Answers  


You suspect that you have two commands with the same name as the command is not producing the expected results. What command can you use to determine thelocation of the command being run?

0 Answers  


What is kill 9 in linux?

0 Answers  


What is nslookup command?

0 Answers  


Can I delete .bash history?

0 Answers  


Working in Linux/Unix platform, if any command dose not work, say # ls reports as command not found. what to do?

5 Answers  


how many hard disks can i able to connect to desktop pc and server (IDE & SATA) pls send this ans to my mail : ping2pavan@gmail.com

1 Answers  


How many linux commands are there?

0 Answers  


What does sh do in linux?

0 Answers  


What is clang format?

0 Answers  


Categories