aboutsummaryrefslogtreecommitdiff
path: root/mvln
diff options
context:
space:
mode:
Diffstat (limited to 'mvln')
-rwxr-xr-xmvln9
1 files changed, 7 insertions, 2 deletions
diff --git a/mvln b/mvln
index 17ff47c..b79feab 100755
--- a/mvln
+++ b/mvln
@@ -7,6 +7,11 @@
# 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
+# Parameters
+ORIG="$1"
+DEST="$2"
+BASE="$(basename "$1")"
+
# Check
if [ ! -e "$1" ]; then
echo "File not found: $1"
@@ -14,5 +19,5 @@ if [ ! -e "$1" ]; then
fi
# Proceed
-mkdir -p `dirname "$2"`
-mv "$1" "$2" && ln -s "$2/`dirname $1`" "$1"
+mkdir -p "$DEST"
+mv "$ORIG" "$DEST" && ln -s "$DEST/$BASE" "$ORIG"