, , ,

bzip2 – compress and decompress

Compress Files using bzip


bzip2 archivefile1.txt

Folder Compression

The “.bz2” file extension is commonly used by the compression program bzip2, which is the counter part of bunzip2. You can use the “-r” option to recursively compress all the files under the specified directory. For example:


tar cvf - foldername | bzip2 > foldername.tar.bz2

Keeping the original uncompressed Files after compression

In order to keep the uncompressed version, you can use the -c option, which writes to standard out, and then re-direct ( “>” ) standard out to a file.


bzip2 -c archivefile1.txt > archivefile1.txt.bz2

> bzip2 –help


bzip2, a block-sorting file compressor.  Version 1.0.6, 6-Sept-2010.

   usage: bzip2 [flags and input files in any order]

   -h --help           print this message
   -d --decompress     force decompression
   -z --compress       force compression
   -k --keep           keep (don't delete) input files
   -f --force          overwrite existing output files
   -t --test           test compressed file integrity
   -c --stdout         output to standard out
   -q --quiet          suppress noncritical error messages
   -v --verbose        be verbose (a 2nd -v gives more)
   -L --license        display software version & license
   -V --version        display software version & license
   -s --small          use less memory (at most 2500k)
   -1 .. -9            set block size to 100k .. 900k
   --fast              alias for -1
   --best              alias for -9

   If invoked as `bzip2', default action is to compress.
              as `bunzip2',  default action is to decompress.
              as `bzcat', default action is to decompress to stdout.

   If no file names are given, bzip2 compresses or decompresses
   from standard input to standard output.  You can combine
   short flags, so `-v -4' means the same as -v4 or -4v, &c.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *