Skip to content

Instantly share code, notes, and snippets.

@photonxp
Last active October 24, 2018 07:54
Show Gist options
  • Save photonxp/f262f24e0557fa85675ff73607add1e6 to your computer and use it in GitHub Desktop.
Save photonxp/f262f24e0557fa85675ff73607add1e6 to your computer and use it in GitHub Desktop.
Make links in current working directory. A "ln -s" wrapper.
#!/bin/bash
# How can we eat the fish any more once we can read their minds? -- The dolphin lady
# Purpose:
# Make multiple links in current working directory. A "ln -s" wrapper.
# Usage:
# lns_multi_cwd.bash lnk_target_path_1 lnk_target_path_2 ...
# lns_multi_cwd.bash /path/dir/*
for fpath_target_raw in "$@"
do
fpath_target="$(echo $fpath_target_raw)"
printf "$fpath_target" | grep '/'
if [ 0 -eq $? ]
then
fpath_target_tail="${fpath_target##*/}"
else
fpath_target_tail="$fpath_target"
fi
ln -s "$fpath_target" "$fpath_target_tail"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment