Create, Extract, See Contents
The tar program takes one of three funcion command line arguments (there are two others I won't talk about).
- c - to create a tar file, writing the file starts at the beginning.
- t - table of contents, see the names of all files or those specified in other command line arguments.
- x - extract (restore) the contents of the tar file.
Compression, Verbose, File specified
In addition to a function command line argument the arguments below are useful. I usually use z and f all the time, and v when creating/extracting.
- f --- specifies the filename (which follows the f) used to tar into or to tar out from; see the examples below.
- z --- use zip/gzip to compress the tar file or to read from a compressed tar file.
- v --- verbose output, show, e.g., during create or extract, the files being stored into or restored from the tar file.
To tar all .cc and .h files into a tar file named foo.tgz use:
tar cvzf foo.tgz *.cc *.h
To see a tar file's table of contents use:
tar tzf foo.tgz
To extract the contents of a tar file use:
tar xvzf foo.tgz