diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2014-05-29 15:07:03 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2014-05-29 15:07:03 -0300 |
commit | 3ca7015a4c572494e54642c132716fb7e6f3157e (patch) | |
tree | 2df9bbf3d9f81540c8a5fdae54fc8f00d00461f1 /mvln | |
parent | 33a9e66447ce8a808669f879ccadadd04e0c00aa (diff) | |
download | scripts-3ca7015a4c572494e54642c132716fb7e6f3157e.tar.gz scripts-3ca7015a4c572494e54642c132716fb7e6f3157e.tar.bz2 |
Adding mvln
Diffstat (limited to 'mvln')
-rwxr-xr-x | mvln | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -0,0 +1,18 @@ +#!/bin/bash +# +# Move a file but keep a symlink behind. +# +# See http://www.linuxquestions.org/questions/linux-newbie-8/script-to-move-old-files-create-symbolic-link-728618/ +# http://lifehacker.com/5270634/move-files-without-breaking-stuff +# https://stackoverflow.com/questions/9251818/bash-move-file-directory-and-create-a-link-of-it +# http://serverfault.com/questions/8108/move-a-file-and-leave-a-soft-link-behind + +# Check +if [ ! -e "$1" ]; then + echo "File not found: $1" + exit 1 +fi + +# Proceed +mkdir -p `dirname $2` +cp "$1" "$2" && ln -sf "$2" "$1" |