Wednesday, November 12, 2008

Extracting .bz2 or .bzip2 files

To extract the file file.bz2, use

bzip2 -d file.bz2

This will an uncompressed file in the current directory called ‘file’ and will delete the original bz2 archive. If you want to keep the original file, add the -k option like

bzip2 -dk file.bz2

A useful option for bzip2 is the -c switch which causes bzip2 to write the uncompressed output to stdout which can easily be redirected to another option. For instance, to search the compressed file file.bz2 for the string tech-recipes, use:

bzip2 -dc file2.bz2 | grep tech-recipes

source:
http://www.tech-recipes.com/rx/1495/extract-a-bz2-or-bzip2-file/

No comments: