Created
July 14, 2015 18:59
-
-
Save blech75/ce73dcf8479982fe761e to your computer and use it in GitHub Desktop.
copy a given list of paths (via stdin) into a new dir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| if [ $# -ne 1 ] ; then | |
| echo "Usage: $0 target_dir " >&2 | |
| exit 1 | |
| fi | |
| TARGET_DIR=$1 | |
| while IFS= read -r f || [[ -n "$f" ]]; do | |
| parent_dir=`dirname $f` | |
| dest="$TARGET_DIR/$parent_dir" | |
| mkdir -p $dest | |
| echo -n "copying $f to ${dest}..." | |
| cp -p $f $dest && echo " done!" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment