photon
9/26/2018 - 11:44 AM

Make links in current working directory. A "ln -s" wrapper.

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