Creating an archive using the ‘tar’ command
Using the tar command
To tar all .a and .b files into a tar file named ab.tgz use:
tar -cvzf ab.tgz *.a *.b
This creates (c) a compressed (z) tar file named ab.tgz (f) and shows the files being stored into the tar file (v). The .tgz suffix is a convention for gzipped tar files.
To archive a full directory testdir into test.tgz:
tar -cvzf testdir.tgz testdir
tar command options
- 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.
- 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.
Advertisement
Leave a Comment