aboutsummaryrefslogtreecommitdiff
path: root/mvln
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-05-29 15:23:30 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-05-29 15:23:30 -0300
commitb04072ea1c6979f17305ce3583dad347e2044dda (patch)
treed6cbc5d4d7710af5d3d72deaf49d4c42096e0b81 /mvln
parentece85f425d2415d179a88ff8a8d04ec4a9ced920 (diff)
downloadscripts-b04072ea1c6979f17305ce3583dad347e2044dda.tar.gz
scripts-b04072ea1c6979f17305ce3583dad347e2044dda.tar.bz2
Using parameters at mvln
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"