The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 09-10-2008
awolbach awolbach is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 1
use symlinks

Quote:
Originally Posted by cfajohnson View Post

What shell are you using? If it's bash or ksh put the list of files in an array, e.g.:


Code:
filelist=( "file 1" "file 2" etc. )

scp "${filelist[@]}" remote.server:path

Or use the list directly on the command line:


Code:
scp "file 1" "file 2" etc. remote.server:path

In these situations you run the risk of exhausting the maximum length of arguments to a process. I ran into this problem today when I needed to randomly divide two massive sets of files evenly between two servers. Create a new directory for each server and fill it with symlinks to the files you wish to copy to that server. If it's a lot of files, automate it by creating a script:


Code:
cat file_list | sed 's/^.*$/ln -s & /' > symlink_script.sh

Execute the script inside of your new directory. Then, just copy that directory over to the target server, and scp will follow the symlinks.