Update: My original answer doesn't work at all, sorry. tar
won't accept a data stream from STDIN as input, so the first command fails.
The only way I can think of to accomplish what you want is to write your own program to add the required tar
headers and such around your data stream. Then you could write:
$ bzcat foo.bz2 | stream-to-tar | bzip - > foo.tar.bz2
... and (assuming your program gets the tar
format right) you could decompress it with a standard tar xf foo.tar.bz2
.
This probably isn't how you want to do it, since it doesn't provide any of the usual advantages of tar'ing the file in the first place.
$ bzcat foo.bz2 | tar cjf foo.tar.bz2 -
Now, the problem is that tar doesn't include any filesystem in it cause all we've given it is a decompressed data stream. That means you need to decompress/untar it like this:
$ tar --to-stdout -xjf foo.tar.bz2 > foo
4Why would you want to do this? – matpie – 2009-10-30T09:28:17.223
Originally it was to work with very large data files without uncompressing them. archivemount lets you mount .tar.bz2 (because it has "filesystem" inside), but not .bz2. – endolith – 2009-10-30T23:47:55.007
http://sourceforge.net/apps/mediawiki/fuse/index.php?title=ArchiveFileSystems – endolith – 2009-10-30T23:50:05.843