Created
April 18, 2017 00:05
-
-
Save dmelo/7a0a62a9954c65c798fe010699c2e00b to your computer and use it in GitHub Desktop.
Switch two symlinks
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 | |
[ -f /tmp/aux-symlink ] && rm /tmp/aux-symlink | |
[ ! -L $1 ] && echo "$1 is not a symlink or doesn't point to a file" && exit 1 | |
[ ! -L $2 ] && echo "$2 is not a symlink or doesn't point to a file" && exit 1 | |
ln -s $(readlink -f $1) /tmp/aux-symlink | |
rm $1 && ln -s $(readlink -f $2) $1 | |
rm $2 && ln -s $(readlink -f /tmp/aux-symlink) $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment