Uncompress Files Compressed with bzip2


Uncompress Files Compressed with bzip2

bunzip2

In the same way that bzip2 was purposely designed to emulate gzip as closely as possible, the way bunzip2 works is very close to that of gunzip.

$ ls -l -rw-r--r-- scott scott  367248 moby-dick.txt.bz2 $ bunzip2 moby-dick.txt.bz2 $ ls -l -rw-r--r-- scott scott 1236574 moby-dick.txt 


You'll notice that bunzip2 is similar to gunzip in another way: Both commands remove the original compressed file, leaving you with the final uncompressed result. If you want to ensure that you have both the compressed and uncompressed files, you need to use the -c option (or --stdout or --to-stdout) and pipe the results to the file you want to create.

$ ls -l -rw-r--r-- scott scott  367248 moby-dick.txt.bz2 $ bunzip2 -c moby-dick.txt.bz2 > moby-dick.txt $ ls -l -rw-r--r-- scott scott 1236574 moby-dick.txt -rw-r--r-- scott scott  367248 moby-dick.txt.bz2 


It's a good thing when commands copy each other's options and behavior, as it makes them easier to learn. In this, the creators of bzip2 and bunzip2 showed remarkable foresight.

Note

If you're not feeling favorable toward bunzip2, you can also use bzip2 -d (or --decompress or --uncompress).




Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net