Ksh/Borne/Bash shell
$ ls /usr/bin
….
# when success value is 0
$ echo $?
0
$ ls /usr/bin/blah
ls: 0653-341 The file /usr/bin/blah does not exist
# when failure non-zero status
$ echo $?
1

c/Tcsh
$ ls /usr/bin
….
# when success value is 0
$ echo $status
0
$ ls /usr/bin/blah
ls: 0653-341 The file /usr/bin/blah does not exist
# when failure non-zero status
$ echo $status
1

One response to “How to find success/failure status of a command in different shells?”

  1. [cli] Find out success status of a command in BASH/ CSH « *NIX tricks Avatar

    […] Credit: Oracle Spin. […]

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.