Tar tutorial

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.


Examples


To tar all .cc and .h files into a tar file named foo.tgz use:

[code lang="shell"]
tar cvzf foo.tgz *.cc *.h
[/code]

To see a tar file's table of contents use:

[code lang="shell"]
tar tzf foo.tgz
[/code]

To extract the contents of a tar file use:

[code lang="shell"]
tar xvzf foo.tgz
[/code]

link: http://www.cs.duke.edu/~ola/courses/programming/tar.html

Komentarze

Popularne posty z tego bloga

Set up JBoss AS 5.1.0 and Seam 2.2.0 in Ubuntu 9.04