[Sussex] Mail for Nik

steve at dobson.org steve at dobson.org
Tue Apr 12 12:55:29 UTC 2005


Hi Goat liker

On Tue, Apr 12, 2005 at 12:36:24PM +0000, sussex at welikegoats.com wrote:
> On Tue, 12 Apr 2005 steve at dobson.org wrote:
> > On Tue, Apr 12, 2005 at 01:25:52PM +0100, Richie Jarvis wrote:
> > > Been trying to remember that nice tar statement you advocated at the
> > > last moot to copy dirs over - can you send it to me please?
> >
> > He didn't get it right on the slide, IIRC, but here is my version that
> > works:
> >
> >   (cd <src-dir> && tar cf - .) | (cd <dst-dir> && tar xcf -)
> 
> Well, I wouldn't use compression, since you are never saving the tar
> anywhere.

It doesn't use compression.  The first "c" is for create. As Richie
spotted the second "c" should be a "v" (verbose) so you can see how
fare it has got.

>            Also, I don't really see the difference between this and cp -a
> src-dir dst-dir ...

Well I don't think cp(1) has an exclude patter argument that tar(1) does.
While it isn't being used here it could be used to omit all the files
ending in ".o" which would save time & disk space.

But the real power is in adding to the pipeline.  Take a look at the
example I am using here which copies from one machine to another.
Compression might have been useful here (the network is the bottleneck).

   $ tar cf - . | ssh root at 10.100.1.198 "cd /usr/src/linux-2.6 && tar xvf -"

That is something you can't do with cp(1).

Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.lug.org.uk/pipermail/sussex/attachments/20050412/8943fb22/attachment.pgp 


More information about the Sussex mailing list