Post

Bash – capture exit code / result of last command

Bash – capture exit code / result of last command

Capturing the exit code of the last command

Basically: Did things go well or were there errors?

1
2
3
4
root@wintermute:/nfs# /etc/init.d/dnsmasq start  
* Starting DNS forwarder and DHCP server dnsmasq [ OK ]  
root@wintermute:/nfs# echo $?  
0

We get “0”, so yes - all is well.

This post is licensed under CC BY 4.0 by the author.