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

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.

You can do it with just one command scp.

  • for newer versions of scp:
scp `find <path> -name <expression>` user@host:<path_where_to_copy>
  • for older versions:
scp --exec=`find <path> -name <expression>` user@host:<path_where_to_copy>

Make sure to encapsulate the find command in between backticks ` and not single quotes '.


for f in `find . -name "*"`;do scp $f phogan@computer/directory;done

Tags:

Linux

Pipe

Scp

Find