3

Tip #44   Using tar with other compression formats

GNU tar comes with native support for gzip, bzip2, and compress (adaptive LZ, LZW). However, many other useful compression algorithms exist, but most implementations of them don't support all the file system metadata that tar does. There are two general methods to using tar with arbitrary compression programs: via an option in tar itself and via piping. The first:
tar -cf foo.tar.ext --use-compress-program generic_compression_program file1 [file2] [file3] [...]

Note that this method is not very configurable and only works with programs that compress by default and will decompress files when invoked with the "-d" option.

The second method:
tar -c file1 [file2] [file3] [...] |generic_compression_program >archive.tar.ext

This method is more versatile, but it requires a bit more shell voo-doo to work (and may not require use of stdout redirection). For instance, to make a .tar.7z archive:
tar -c list of files and directories to compress |7z a -si outfile.tar.7z

To uncompress said archive:
7z e -so infile.tar.7z |tar -x