Created
August 21, 2014 07:53
-
-
Save lyuboraykov/5701b39be46e4d7b5a0e to your computer and use it in GitHub Desktop.
Try-catch file copying in bash
This file contains 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
#!/usr/bin/env bash | |
{ | |
#try block | |
cp non/existing/file non/existing/folder | |
} || { | |
#catch block | |
if [ $? != 0 ]; then | |
echo "File copying failed." | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment