Untitled Document
bzip2 & bunzip2 Command

The bzip2 and bunzip2 - are the file compression/ uncompression commands , which reduces the file size stored in disk .On compression the new file with .bz2 extension is created .We have added some basic examples of these two commands in this page . Mostly people use tar , zip and gzip commands for file compression and archival . Even we will suggest you to you these commands as most of the users might not aware of about .bz2 file extension .

command - bzip2 

Example 1 -

This will compress the file user.txt and creates new file user.txt.bz2 and removes the orignal user.txt from current directory .

   bzip2 user.txt    
   output - user.txt.bz2

Example 2 -

We can compress multiple files with bzip2 command

   bzip2 list.txt user.txt emp.csv   
   output - list.txt.bz2 user.txt.bz2 emp.csv.bz2

Example 3 -

we can compress the file and keep the orignal fle as it is using -k option . The below command compresses the user.txt file and keep the orignal file as its is

   bzip2 -k user.txt  

command - bunzip2 

Example 1 -

This will uncompress the file user.txt.bz2 and restores the old file user.txt. and removes the orignal user.txt.bz2 from current directory .To uncompress it we have to use -d option .
   bzip2 -d user.txt.gz2 or 
   bunzip2 user.txt.gz2
   output - user.txt.

Example 2 -

We can uncompress multiple files with bzip2 command

   bunzip2 list.txt.bz2 user.txt.bz2 emp.csv.bz2   
   output - list.txt user.txt emp.csv

Example 3 -

we can un compress the file and keep the orignal fle as it is using -k option . The below command uncompresses the user.txt.bz2 file and keep the orignal file as its is

   bunzip2 -k user.txt.bz2
   output - user.txt
For some years , gzip reigned as the msot favored compression agent. Today, we have a better agent in bzip2 ( and bunzip2 ). bzip2 is slower than gzip and creates .bz2 files. We are begining to see .bz2 files on the Internet . bzip2 options are modeled on gzip , so if you know gzip you also know bzip2.
Untitled Document