Skip to content

Instantly share code, notes, and snippets.

@jraleman
Created November 22, 2018 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jraleman/c48d11805eadf3089cc6db20f11cc38a to your computer and use it in GitHub Desktop.
Save jraleman/c48d11805eadf3089cc6db20f11cc38a to your computer and use it in GitHub Desktop.
Swap two file from one location to another location
#!/bin/sh
if [ $# -ne 2 ] ; then
echo "usage: $0 source_file target_file" ;
exit 1 ;
else
[ -e $1 ] && [ -e $2 ]
tmp=$(mktemp)
mv -fv $1 $tmp
mv -fv $2 $1
mv -fv $tmp $2
exit 0 ;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment