cp and scp
Apr. 5th, 2010 07:56 pmI am in a directory with a number of folders, each of which has a file named
I would like to copy only these files, while preserving directory structure.
If I do
I want to specify which files match separately from the root directory from which I am recursively copying.
Is this one of the rare uses of the
out.csvI would like to copy only these files, while preserving directory structure.
If I do
scp -r gusl@ubc.ca:my-project/*/out.csv my-project/ then all the copies of out.csv get copied into the base of my-project, erasing each other.I want to specify which files match separately from the root directory from which I am recursively copying.
Is this one of the rare uses of the
--copy-contents option?
(no subject)
Date: 2010-04-06 03:17 am (UTC)(a) a short shell script, or
(b) the GNU tar --include-files option (or something like that).
scp is slow when multiple files are involved, so you usually want to run
tar cf - a b c | ssh -c 'tar xf -'(or something like that -- I'm not testing these suggestions, just giving something similar to the truth)(no subject)
Date: 2010-04-06 03:35 am (UTC)find ... | xargs tar cf - ... | ssh -c 'tar xvf - ...'
or, if find isn't smart enough, a shell, Perl, or Ruby script to identify the files; or I will use rsync -e ssh if it's available on both ends.
I'm not aware of --copy-contents and I don't see it in the man pages for scp from OpenSSH 4.3p2 or OpenSSH 5.2p1, which suggests at a minimum that it is unportable. tar and find are present on any Unix system, though non-GNU finds and tars can get pretty stupid. (The only place I see "--copy-contents" on the tubes is in the "cp" manpage, and no, it's not the right thing to use there.)
(no subject)
Date: 2010-04-06 09:00 am (UTC)# rsync -avP --include='foo' --filter 'hide,! */' src/ dst/
--copy-contents is for inodes that are neither directories or files (fifos, device nodes, named pipes, symlinks etc).
(no subject)
Date: 2010-04-06 11:38 am (UTC)(no subject)
Date: 2010-04-06 03:41 pm (UTC)A suggestion that hasn't been mentioned is unision, which will keep directories in sync between computers. Good if you want to do this over time, or if you have a 'home', 'work' and 'travel' system that you want to keep the same files on. It's like rsync, but at a higher level.
(no subject)
Date: 2010-04-06 05:07 pm (UTC)(no subject)
Date: 2010-04-06 05:07 pm (UTC)