How to make a tar archive |
|
To construct a ``tarball'' that contains copies of all the files in a particular directory subtree:
cd /u/gertrude/rain
tar -cvzf name.tgz subdir
where subdir is the name of the subdirectory you want
to save. To continue the example, this command would be:
tar -cvzf rainpics.tgz pics
The -c option tells tar to create an archive. The v option tells it to write out the names of the files on your screen as it saves them, so you can be sure it is including everything you want. The z option specifies that the file should be compressed, to save space. The f option instructs tar to use the next name (in the example, rainpics.tgz) for the tarball it is building.
The last argument is the name of the directory subtree to be saved. You could use an absolute path name here, but it is not recommended, because you may be moving the tarball to a system that has different directories. That's why we recommend you use a relative path name here.
Once your tarball file is completed, you can move or copy it elsewhere on the system, or to a different system altogether.
|
John Shipman, john@nmt.edu
Last updated: 2000/09/20 21:22:12 UT URL: http://www.nmt.edu/tcc/help/unix/tar_build.html |
|