Last active
April 26, 2017 04:57
-
-
Save handakumbura/8d424dd4023d67de8a7a77d859fd6720 to your computer and use it in GitHub Desktop.
Error handling with status codes in BASH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#do something if error code denotes a failure | |
if [ $? -gt 0 ]; then | |
echo "something went wrong!" | |
fi | |
#status checking in command pipe | |
cat textfile.txt | ( [[ $? == 0 ]] && grep "cat" ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment