Difference between revisions of "last command exit status"

From thelinuxwiki
Jump to: navigation, search
(Created page with "useful in bash to execute a command based on the previous command's exit status if [ $? == 0 ]; then echo "last command worked dude! exit status was 0" fi if [ $? ==...")
 

Latest revision as of 16:47, 31 May 2014

useful in bash to execute a command based on the previous command's exit status

if [ $? == 0 ]; then 
  echo "last command worked dude! exit status was 0"
fi
if [ $? == 1 ]; then 
  echo "last command failed dude! exit status was 1"
fi