Reputation: 827
I have a specific list of files that I need to copy from a remote server. Is this possible with SCP?
I know I can copy individual files using scp {user_name}@{host}:{filepath} .
, but is there any way to take a .csv
or .txt
and run a foreach loop?
Upvotes: 6
Views: 14736
Reputation: 622
I found that it was easier to use tar with a list then send the files individually via scp:
tar -czvf archive.tar.gz -T file-list.txt && scp archive.tar.gz user@host:/path/
I use this on systems that don't have rsync available, this way you also avoid iterating password prompts or TCP/SSH connection limits.
Upvotes: 3
Reputation: 157
while read file; do scp "user@host:$file" .; done < files
Upvotes: 11