Created
May 13, 2013 13:28
-
-
Save mintsoft/5568286 to your computer and use it in GitHub Desktop.
Swap two files on disk
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
#!/bin/bash | |
if [[ ! -e "$1" ]] || [[ ! -e "$2" ]]; then | |
echo -e "Please specify files that exist:"; | |
echo -e "\tFor example: $0 fileOne fileTwo\n"; | |
exit 1; | |
fi | |
echo "Swapping Files: $1 $2"; | |
mv "$1" ".tmp.$1"; | |
mv "$2" "$1"; | |
mv ".tmp.$1" "$2"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment