Sunday, November 26, 2006

Tar gzip and Bzip2 usage

Tar and bzip2 in one command:
tar -cf - /etc/ | bzip2 > etc.tar.bz2
tar -cjvf etc.tar.bz2 /etc/

Tar and gzip in one command:
tar -cvzf file.tar.gz files (GNU tar)
tar -cvf - files | gzip > file.tar.gz

List contents of gzip file:

gzcat file.tgz | tar -tvf -
gunzip < file.tgz | tar -tvf -

To Extract gzip (.tar.gz /.tgz) files:
gunzip < file.tgz | tar -xvf -
gzcat file.tgz | tar -xvf -
tar -zxvf file.tgz

List contents of bzip2 file:
bzcat jazwww.tar.bz2 | tar -tvf -
bzip2 -cd jazwww.tar.bz2 | tar -tvf -

To Extract bzip2 files:
bzcat jazwww.tar.bz2 | tar -xvf -
bzip2 -cd jazwww.tar.bz2 | tar -xvf -

To List or Extract a subset of files from a tar:
tar -tvf jazwww.tar usr/bin/
tar -xvf jazwww.tar usr/bin/
bzip2 -cd jazwww.tar.bz2 | tar -tvf - usr/bin/

# -p option preserves original permissions upon extract


http://en.wikipedia.org/wiki/Bzip2
http://www.gzip.org/

No comments: