Skip to content

Instantly share code, notes, and snippets.

@anonur
Created March 25, 2019 10:58
Show Gist options
  • Save anonur/acf04a2fbbde4f16cdf0d876e6eda2c8 to your computer and use it in GitHub Desktop.
Save anonur/acf04a2fbbde4f16cdf0d876e6eda2c8 to your computer and use it in GitHub Desktop.
Tests if the given command executed successfully.
#!/bin/bash
#Filename: success_test.sh
CMD="command" #Substitute with command for which you need to test the exit status
$CMD
if [ $? -eq 0 ];
then
echo "$CMD executed successfully"
else
echo "$CMD terminated unsuccessfully"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment