//View Tip #44
Similar Tips
» Pipe files to an archive
» network copy with ssh and tar
» Tar remote dir over SSH
» Finding Newer Files [OR How To Create A Patch File]
» Bash function to decompress archives

 

Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
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


View Comments »




Comments 

Add your comment

Comments are currently disabled
No Comments

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit