User Tools

Site Tools


eric:computer:bash:shell_scripting:shell.scripting.exit.results

Title: Shell.Scripting.Exit.Results
Created: 2012-10-23 04:33:02 +0000

Bash shell scripting notes – Determining a Command’s Exit Result

Say you want to know if a command in a shell script executed successfully, how do you test it’s exit code in a shell script?

touch some.file
if [ "$?" = "0" ]; then
   # success here
   echo "touch command worked"
else
   # failure here
   echo "could not touch some.file"
fi
eric/computer/bash/shell_scripting/shell.scripting.exit.results.txt · Last modified: by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki