Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ -z "$2" ]; then
- echo "Usage: copy_with_links one_or_more_source_files target_directory/"
- exit 1
- fi
- set -e
- f=("$@")
- d=${f[${#f[@]}-1]}
- d=$(readlink -f "$d")
- # remove the target directory from list of files
- unset f[${#f[@]}-1]
- for a in "${f[@]}"; do.
- b=$(readlink -f "$a")
- dn=$(dirname "$b")
- for q in $(find -L "$dn" -maxdepth 1 -mindepth 1 -samefile "$b"); do
- cp -ai "$q" "$d/"
- done
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement