Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcnc!rti-sel!dg_rtp!meissner From: meissner@dg_rtp.UUCP (Michael Meissner) Newsgroups: comp.unix.questions Subject: Re: Sys V does not have a recursive copy cmd... Message-ID: <811@dg_rtp.UUCP> Date: Wed, 7-Jan-87 14:06:55 EST Article-I.D.: dg_rtp.811 Posted: Wed Jan 7 14:06:55 1987 Date-Received: Wed, 7-Jan-87 23:10:24 EST References: <1269@cadovax.UUCP> <1964@ptsfa.UUCP> <487@obelix.UUCP> Reply-To: meissner@dg_rtp.UUCP (Michael Meissner) Organization: Data General (Languages @ Research Triangle Park, NC.) Lines: 49 In article <487@obelix.UUCP> sven-e@obelix.UUCP (Sven L Eriksson) writes: >In article <1964@ptsfa.UUCP> jmc@ptsfa.UUCP (Jerry Carlin) writes: >>In article <1269@cadovax.UUCP> mitchell@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