Linux – Using scp to transfer a .txt file list of files

linuxscpssh

I have 1.6 million files on server A, and only about 20k of them need to get to server B. The destination, server B, is on GoDaddy shared hosting, so I'm just about limited to scp for transferring many files at once.

I'd like to generate a .txt file of those 20k+ files from an SQL query, then feed that list into scp. Are there any options to do so?

cat /proc/version gives me Linux version 2.6.32-531.23.3.lve1.2.65.el6.x86_64 (mockbuild@koji.cloudlinux.com) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Tue Aug 19 10:37:27 EDT 2014

Best Answer

if you have the text file already created you do the following

cat /location/file.txt | xargs -i scp {} user@server:/location

this will go line by line of the output of the file.txt and run the scp comamand per line; I hope this helps.

Related Question