bzip2 compresses files using the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding.bzip2 expects a list of file names to accompany the command-line flags.Each file is replaced by a compressed version of itself, with the name "original_name.bz2". bzip2 and bunzip2 will by default not overwrite existing files.If you want this to happen, specify the -f flag. If no file names are specified, bzip2 compresses from standard input to standard output.In this case, bzip2 will decline to write compressed output to a terminal, as this would be entirely incomprehensible and therefore pointless. bunzip2 will correctly decompress a file which is the concatenation one two or more compressed files. The result is the concatenation of the corresponding uncompressed files. Integrity testing (-t) of concatenated compressed files is also supported.
Gzip reduces the size of the named files using Lempel-Ziv coding (LZ77).Whenever possible, each file is replaced by one with the extension .gz, while keeping the same ownership modes, access and modification times.(The default extension is -gz for VMS, z for MSDOS, OS/2 FAT, Windows NT FAT and Atari.) If the compressed file name is too long for its file system, gzip truncates it. Gzip attempts to truncate only the parts of the file name longer than 3 characters.(A part is delimited by dots.) If the name consists of small parts only, the longest parts are truncated. For example, if file names are limited to 14 characters, gzip.msdos.exe is compressed to gzi.msd.exe.gz. Names are not truncated on systems which do not have a limit on file name length.
gunzip can currently decompress files created by gzip, zip, compress, compress -H or pack. The detection of the input format is automatic. When using the first two formats, gunzip checks a 32 bit CRC. For pack, gunzip checks the uncompressed length. The standard compress format was not designed to allow consistency checks. How‐ever gunzip is sometimes able to detect a bad .Z file. If you get an error when uncompressing a .Z file, do not assume that the .Z file is correct simply because the standard uncompress does not complain. This generally means that the standard uncompress does not check its input, and happily generates garbage output. The SCO compress -H format (lzh compression method) does not include a CRC but also allows some consistency checks.
Take a look at here.