Compressing and Extracting Files
Back to current version Restore this version

Tar#

Archive/Compress#

Creates a GZIP-compressed Tar file of the name eglinux.tar.gz of all files with a .txt suffix.

$ tar -czf eglinux.tar.gz *.txt

Make a compressed archive of a folder (recursively):

$ tar -czf target.tar.gz folder/*
$ tar -cjf file.tar.bz2 dir

Tar/Gz Using Pipes#

To compress current directory

tar cvf - . | gzip > target.tar.gz

To compress only text files

tar cvf - *.txt | gzip > target.tar.gz

XZ#

XZ (used exactly like gzip) is on the order of 30% better than gzip and 15% better than bzip2.

Parallel Optimization#

Pigz is a parallel implementation of gzip

tar cvf - . | pigz > target.tar.gz

Pbzip2 is a parallel implementation of bzip2

tar cvf - . | pbzip2 > target.tar.bz2

Pixz is a parallel implementation of xz

pixz -9t -p8 filename filename.pxz

View#

List files in a compressed Tar file

$ tar -tzf eglinux.tar.gz

Extract#

Extracts all files from a compressed Tar file of the name eglinux.tar.gz.

$ tar -xf eglinux.tar.gz

or

tar -zxvf Python-2.5.2.tgz

To extract to a specific folder

$ tar -xf eglinux.tar.gz -C ~/des

To extract a bz2, tar.bz2, bzip2 file:

bzcat Python-2.5.2.tar.bz2 | tar -xf -

or

tar xvfj Python-2.5.2.tar.bz2

CategoryComputing - Performance