How do I copy all files with scp in 1 command?

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Thu May 16 14:58:46 UTC 2013


On Wed, May 15, 2013 at 06:46:25PM -0400, John Sellens wrote:
> scp, like cp and mv, can take multiple source files, and indeed,
> you are already doing that - the * expands to multiple files.
> 
> Virtually anywhere you use one shell wildcard, you can use more than one.
> 
> So:
> 
>     scp * .??* new_machine:/home/waltdnes/
> 
> I use ".??*" to avoid matching . or .. (the directories) and because
> I rarely have files named with a period and one character.
> 
> As others mentioned, you can of course use scp's -r option, if you
> want to recursively copy an entire directory.
> 
>     scp -p -r . new_machine:/home/waltdnes/
> 
> -p means retain dates and owner/group/mode.
> 
> And of course, rsync is a good choice as well, especially if your
> copy might be interrupted in the middle somewhere:
> 
>     rsync -av . new_machine:/home/waltdnes/
> 
> Hope that helps - cheers!

Also with the right options rsync can maintain sparse files, hard links,
etc, which scp doesn't.

-- 
Len Sorensen
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list