From: Ivan Shmakov on
>>>>> Jim <student.northwestern(a)> writes:


> I have a directory called archives. I want to find all the files
> ending with ".mbox", and I want to scp all those files to another
> server. but the trick is that I need to preserve the directory
> structure.

> I came up with something like

> find archives -name "*.mbox" | xargs scp user(a)server:/somedir, but
> this does not preserve the directory structure(does not create parent
> directory if necessary)..

> Thank you for any pointers!

It's not quite an answer to the question asked, but why not to
try Rsync instead? Like:

$ rsync -vaO \
--include=\*/ \
--include=\*.mbox \
--exclude=\* \
archives/ \

Obviously, Rsync should be installed on both the local and the
remote host.

Note that a slash ('/') after a source directory name is
significant. Namely,

$ rsync ... from user(a)server:/to/

is (roughly) equivalent to:

$ rsync ... from/ user(a)server:/to/from/

It may be said that 'from' refers to the directory, while
'from/' refers to its /contents/.

FSF associate member #7257