3

I am trying to move very big file from one host to another host. Also the file names are too large so I have to use xargs. Also all the sub directories need to be copied also

I am using the below command in the source host current directory

find . -name "*" -type f -print0 | xargs -0 scp -r UserName@host:/path/to/destination

but it is throwing below error

scp: /path/to/destination: not a regular file
Anirban Nag 'tintinmj'
  • 1,115
  • 1
  • 10
  • 10
  • Are you asking how to [Make xargs pass as first parameter](http://unix.stackexchange.com/questions/91596/make-xargs-pass-as-first-parameter?) – steeldriver Aug 20 '16 at 13:07
  • 3
    Why can't you just do `scp -r . userame@host:/path/to/destination` and avoid the `find`/`xargs` bit? – Stephen Harris Aug 20 '16 at 13:09
  • @StephenHarris cause the file names are too big, so it is giving error as `ksh: line 1: /usr/bin/scp: cannot execute [Argument list too long]` – Anirban Nag 'tintinmj' Aug 20 '16 at 13:37
  • Did you do `scp -r *` instead of `scp -r .` to get that argument list too long error? Apart from `scp`, you could use `tar cf - . | ssh user@somewhere tar xf -` – ilkkachu Aug 20 '16 at 14:16
  • 1
    `find` finds *all* files (and directories, etc.) by default; tests like `-type`, `-mtime`, `-name`, `-user` and `-group` then refine/restrict the search results by eliminating files (etc.) that don't satisfy the test. But the filename pattern `*` means "all"; it doesn't restrict or eliminate anything. Therefore, `-name "*"` has no effect in a `find` command. – Scott - Слава Україні Aug 20 '16 at 20:42

1 Answers1

3

find . -type f -print0 | xargs -0 -I {} scp {} UserName@host:/path/to/destination

user1700494
  • 2,172
  • 8
  • 13