file compression and archiving: zip, unzip, bzip2, and tar
zip, unzip, bzip2, and tar are file compression and archiving tool in unix like systems.
gzip and bzip2 are for compressing single file. bzip2 is more efficient than gzip to compress the file but takes more time to do the compression.
zip and tar are for compressing and archiving file. tar can use gzip or bzip2 to do the comopress and then archive.
gzip, compress the given files with Lempel-Ziv coding.
gzip data.txt #compress data.txt to data.txt.gz gzip data1.txt data2.txt #compress data1.txt and data2.txt to data1.txt.gz, data2.txt.gz gzip *.txt #compress all the txt files in the current directory
gunzip, decompress the gz files
gunzip data.txt.gz #decompress data.txt.gz to data.txt gunzip data1.txt.gz data2.txt.gz #decompress data1.txt.gz and data2.txt.gz to data1.txt, data2.txt gunzip *.gz #decompress all the gz files in the current directory
bzip2, compress files with the Burrows-Wheeler block sorting text compression algorithm and Huffman coding.
bzip2 data.txt #compress data.txt to data.txt.bz2 bzip2 data1.txt data2.txt #compress data1.txt and data2.txt to data1.txt.bz2, data2.txt.bz2 bzip2 *.txt #compress all the txt files in the current directory
bzip2 -d, decompress bz2 files
bzip2 -d data.txt.bz2 #compress data.txt.bz2 to data.txt bzip2 data1.txt data2.txt #compress data1.txt.bz2 and data2.txt.bz2 to data1.txt, data2.txt bzip2 *.bz2 #compress all the bz2 files in the current directory
zip, compressing file and packaging it into a zip file, keeping the input file untouched.
zip data.zip data1.txt data2.txt #compressing data1.txt and data2.txt and packaging them into data.zip
unzip, extract compressed files from a zip package.
unzip data.zip #extracting files from data.zip
tar, compressing and archiving files. It supports archive compressing through gzip and bzip2. If you are compressing more than 2 files, tar is recommended instead of gzip or bzip2
tar -zcvf data.tgz data1.txt data2.txt #compress and archive data1.txt and data2.txt into data.tgz using gzip compress tar -jcvf data.tbz2 data1.txt data2.txt #compress and archive data1.txt and data2.txt into data.tbz2 using bzip2 compress
tar, extract compressed files from tgz and tbz2 file
tar -zxvf data.tgz tar -jxvg data.tbz2
Search within Codexpedia
Search the entire web