ln -s: from one source to many destinations
You can't do this with a single invocation of ln
,but you could loop through all necessary destinations:
$ for i in "$HOME/Documents/" "$HOME/Desktop/"; do ln -s "$HOME/file" "$i"; done
If you have gnu parallel
you could try with
parallel ln -s /path/file {} ::: /path/dest1 /path/dest2 /path/dest3
or, to symlink multiple targets to (the same) multiple destinations
parallel ln -s {1} {2} ::: /path/file1 /path/file2 ::: /path/dest1 /path/dest2
It's no less verbose than two separate ln -s
invocations:
echo $HOME/Documents/ $HOME/Desktop/ | xargs -n 1 ln -s $HOME/file
but that only works for absolute paths (because symbolic links are interpreted relative to their parent directory, unless they're absolute).
(The relative cost drops of course as the number of links goes up. Also, this snippet relies on the fact that $HOME
doesn't contain any spaces, tabs or newlines.)