From 3ca7015a4c572494e54642c132716fb7e6f3157e Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 29 May 2014 15:07:03 -0300 Subject: Adding mvln --- mvln | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 mvln (limited to 'mvln') diff --git a/mvln b/mvln new file mode 100755 index 0000000..2b921ca --- /dev/null +++ b/mvln @@ -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" -- cgit v1.2.3