Jump to navigation Jump to search
To see exit status of the script, enter (see [[the exit status of a command]] for more information about special shell variable $?) :
<syntaxhighlight lang="bash" >echo $?</syntaxhighlight>
===Exit status at the CLI===
Exit status is not limited to shell script. Every time command terminated shell gets an exit code indicating success or failure of the command. Hence we can use the particular bash variable $? to get the exit status of the command. For instance:
<syntaxhighlight lang="bash" >ping -q -c 4 >/dev/null
echo $?</syntaxhighlight>
In this example, we will see the exit status of the last command (command3) only:
<syntaxhighlight lang="bash" >command1 | command2 | command3
## will get the exit status of the last command in the pipeline ##
echo $?</syntaxhighlight>
==Shell script example==
* Any non zero value indicates unsuccessful shell script termination.

Navigation menu