Monday, September 20, 2021

What is the meaning of $? in a shell script? - Unix & Linux Stack Exchange

Source:


run_some_command  EXIT_STATUS=$?    if [ "$EXIT_STATUS" -eq "0" ]  then      # Do work when command exists on success  else      # Do work for when command has a failure exit  fi

#Alternatively:

if run_some_command  then      # Do work when command exists on success  else      # Do failure exit work  fi


No comments: