Wednesday, January 16, 2008

Tar and Gzip

I always forget the tar and gzip process.. so here is my quick reference.

Creating a tape archive:
tar -cf archive.tar myDirectories/
Note - using the "v" flag prints out extra messages, as verbose mode, though it's not related to extracting files.

Listing the contents of an archive:
tar -tf archive.tar

Extracting all files from an archive:
tar -xf archive.tar
To extract just partial pieces from the archive, supply a file or directory name after the archive name. You can list as many as desiered here, separated by spaces.
tar -xf archive.tar filename

gzip archive.tar

gunzip archive.tar.gz

Merged filenames:
Sometimes, you will download files ending with the extension *.tgz - these are essentially identical to files ending with *.tar.gz files. You can gunzip them, and untar them just the same way. If you're working with a recent version of gnu tar, you may be able to take a shortcut, as described below.

No comments: