Skip to content

Instantly share code, notes, and snippets.

@mintsoft
Created May 13, 2013 13:28
Show Gist options
  • Save mintsoft/5568286 to your computer and use it in GitHub Desktop.
Save mintsoft/5568286 to your computer and use it in GitHub Desktop.
Swap two files on disk
#!/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