Piping output of tar(1) into another tar(1) command

Mark Ovens mark at ukug.uk.freebsd.org
Mon Nov 20 17:04:14 GMT 2006

I'm sure this is possible, but I can't work it out....

I have a massive Gzip'd tar archive that I need to put onto tape (DAT) 
as I need the disk space. I don't have enough disk space to extract the 
archive to a temporary location in order to archive it to tape therefore 
I need to do it directly by piping the output of the archive extraction 
to the tar(1) command to write it to tape.

I tried this (using a small test archive to prevent disaters):

tar xzvf foobar.tgz | tar cvf wibble.tar -

which, as I half-expected, didn't work and neither did this:

tar xzvf foobar.tgz -C - | tar cvf wibble.tar -

tar: could not chdir to '-'

I'm sure I've seen this done, but how? Or am I thinking about when 
dump(8) is used, piped into tar(1) to write it to tape?

Anyone know how to do this?




More information about the Ukfreebsd mailing list