Last active
January 13, 2021 12:38
-
-
Save simonthompson99/3dc7793d007801b05c333806990997e4 to your computer and use it in GitHub Desktop.
[rsync rename] Rsync set of files then rename #bash #file_operations
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
#!/bin/bash | |
# script to rsync then move load of files, quicker than individual scp | |
# usage: bash rsync_rename.sh files.txt | |
# where files.txt is a pipe-separated file of <remote_path>|<local_path_to_move_to> | |
input_file=$1 | |
files_to_rsync=$(cut "-d|" -f1 $input_file) | |
echo $files_to_rsync | tr " " "\n" | rsync -arvzh --progress [email protected]:/ /tmp --files-from=- | |
cat $input_file | while IFS='|' read src dest; do | |
src="/tmp${src}" | |
mkdir -p "$(dirname "${dest}")" | |
cp $src $dest | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment