Sys V does not have a recursive copy cmd...

Michael Meissner meissner at dg_rtp.UUCP
Thu Jan 8 05:06:55 AEST 1987


In article <487 at obelix.UUCP> sven-e at obelix.UUCP (Sven L Eriksson) writes:
>In article <1964 at ptsfa.UUCP> jmc at ptsfa.UUCP (Jerry Carlin) writes:
>>In article <1269 at cadovax.UUCP> mitchell at cadovax.UUCP (Mitchell Lerner) writes:
>>>
>>>... System V does not have a cp that does recursive copies...
>>
>>Try "find . -print|cpio -pduvm /foo/bar/...".
>>
>Another way to do this copy is to use tar. (Tape file ARchiver)
>
>	tar cf - . | (cd todir ; tar xf - )
>
>If you use this command links between files in the tree will be kept.
>Otherwise it will work exactly as the find|cpio version.

Some nits:

    1)	find ... | cpio -p...  does preserve links as well;

    2)	If you are copying with find|cpio, use the -depth switch (so the
	files within a directory are copied before changing the directory
	permissions (useful if you are copying a directory subtree where
	the directory is set read-only).  The command would then look like:

		find . -depth -print | cpio -pduvm /foo/bar/...

    3)	If you are copying to same file system, you can add the 'l' option
	to the cpio, and it will try to link the copied file to the original
	before doing a copy (saves on disk space).  The command would be:

		find . -depth -print | cpio -plduvm /foo/bar/...

    4)	Some early 3B system V.0 did not supply tar.

    5)	If the files are large, I would imaging the find|cpio solution would
	be much faster than the two tar's (the data in the file is only
	copied once, plus the pathnames which are read/written to the pipe
	compared to the first tar writing everything into a pipe, and the
	second tar reading the pipe and writing it to the disk).

    6)	Find|cpio is more general, because you can selectively copy portions
	of the subtree, instead of the whole thing.  For example, if I wanted
	to copy a subtree, except for the emacs (CCA based) backup files, I
	would do:

		find . -depth ! -name "*~" -print | cpio -plvudm /foo/bar
-- 
	Michael Meissner, Data General
	...mcnc!rti-sel!dg_rtp!meissner



More information about the Comp.unix.questions mailing list