Created
August 31, 2015 21:36
-
-
Save kostasdizas/1dcc041067812b04c39a to your computer and use it in GitHub Desktop.
Quickly copy a file or folder elsewhere and replace it with a symlink pointing to its new location
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 [[ -z $1 ]] || [[ -z $2 ]]; then | |
echo "arguments missing" | |
exit 1 | |
fi | |
one=${1%/} | |
two=${2%/} | |
echo "$one will now be in $two/$one" | |
mkdir -p $two/$(dirname $one) | |
mv $one $two/$one | |
ln -s $two/$one $one |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment