bzip2 [ Home | Documentation | Downloads ]

3.2. Using bzip2 with tar

Listed below are three ways to use bzip2 with tar.

3.2.1. 1. Easiest to setup

This method requires no setup at all. To un-tar the bzip2'd tar archive foo.tar.bz2 in the current directory, do:

/path/to/bzip2 -cd foo.tar.bz2 | tar xf -


tar --use-compress-prog=bzip2 xf foo.tar.bz2

These work, but can be a PITA to type often.

3.2.2. 2. Easy to set up, fairly easy to use, no need for root privileges:

Thanks to Leonard Jean-Marc for the tip. Thanks also to Alessandro Rubini for differentiating bash from the csh's.

In your .bashrc, you can put in a line like this:

alias btar='tar --use-compress-program /usr/local/bin/bzip2'

In your .tcshrc, or .cshrc, the analogous line looks like this:

alias btar 'tar --use-compress-program /usr/local/bin/bzip2'

3.2.3. 3. Also easy to use, but needs root access

Update your tar to GNU's newest version, which is currently 1.13.10. It can be found at GNU's ftp site or any mirror.

Copyright © 1996 - 2018