Just a place where to dump some code to the community.
jueves, 25 de junio de 2009
Error handling in Bash
To check if a command was successfully run in our bash script, we have to check the value of its output, which is stored in the $? variable. If its value equals to 0, then the command was successful, otherwise, an error was thrown:
rm ~/data.tar.bz2 if [ "$?" != 0 ]; then echo "ERROR: Could not delete file" exit 1 fi