Tar, Gzip, Bzip2, Zip

By linatrix

Features:

1. Compression utilities (gzip, bzip2, zip)

2. File rollers (the ability to represent many files as one)

Gzip:

Includes:

1. gzip – compresses/decompresses files

2. gunzip – decompresses gzip files

Tasks:

1. compress ‘1million.txt’ file using gzip

a. gzip -c 1million.txt > 1million.txt.gz

Note: gzip auto-dumps to STDOUT, by default

b. gzip -l 1million.txt.gz – returns status information

c. gunzip 1million.txt.gz – dumps to file, and removes compressed version

d. gzip -d 1million.txt.gz

e. zcat 1million.txt.gz – dumps the contents to STDOUT zcat file.gz > file2.txt

f. less 1million.txt.gzip – dumps the contents of gzip files to STDOUT

Bzip2: better compress

  1. bzip2 -c 1million.txt > 1million.txt.bz2

Note: Bzip2 tends to outperform gzip on larger files

2. bunzip2 1million.txt.bz2

3. bzip2 -d 1million.txt.bz2

4. bzcat 1million.txt.bz2 – dumps contents to STDOUT

5. less 1million.txt.bz2 – also dumps the contents to STDOUT

Zip & unzip:

1. zip filename.zip path/ – general usage

2. zip 1million.txt.zip 1million.txt

Note: zip differs slight from gzip and bzip2 in that the destination file (resultant zip file) is specified before the source

  1. unzip 1million.txt.zip

Tar & Gzip/Bzip2:

1. tar -cvf filename.tar path/ – creates a non-compressed archive

  1. tar -cvf 1million.txt.tar 1million.txt

Note: tar, requires a small overhead for itself in each file

3. tar -czvf 1million.txt.tar.gz 1million.txt – creates, tar/gzip document

4. tar -cjvf 1million.txt.tar.bz2 1million.txt – creates, tar/bzip2 document

  1. tar -tzvf display archive content
  2. tar -xzvf extract archive content

6. tar -cjvf 1million.txt.tar.bz2 1million.txt testRH5/- creates, tar/bzip2 document for the text file and ‘testRH5′ directory tree

Tags:

Leave a Reply