Linux – I would like to pipe output of find into input list of scp, how

findlinuxpipescp

I'm a novice linux user and I am trying to send a long list of files from one computer to another. The argument list is too long, so I am using find. I am having trouble setting up the expression, though. Can someone help?

Here is what I would normally type for a short argument list.

scp ./* phogan@computer/directory...

Here's I think this might translate into with find.

scp find . -name "*" phogan@computer/directory...

Maybe I could use piping? Any suggestions would help. Thanks in advance.

Best Answer

find . -name "*" -exec scp '{}' phogan@computer:/directory ';'

Normally I would 'tar' all the files together into one huge blob and call 'scp' just once. Something like this:

tar czfv - file1 file2 dir1 dir2 | ssh phogan@computer/ tar xvzf - -C directory
  • One could play around with the --exclude= or --include= parameters of tar.
  • Another option would be to use rsync.
Related Question