Skip to content

Instantly share code, notes, and snippets.

@drzhbe
Last active August 29, 2015 14:02
Show Gist options
  • Save drzhbe/9dd0f73952d56c845dfc to your computer and use it in GitHub Desktop.
Save drzhbe/9dd0f73952d56c845dfc to your computer and use it in GitHub Desktop.
# swap names of 2 files
if [ $# -eq 2 ]
then
mv $1 $1.backup
mv $2 $1
mv $1.backup $2
fi
# swap %file_name% with %file_name%.backup
if [ $# -eq 1 ] && [ -f $1.backup ] || [ -d $1.backup ];
then
mv $1 $1._backup
mv $1.backup $1
mv $1._backup $1.backup
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment