Skip to content

Creating an archive using the ‘tar’ command

May 23, 2010

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

From → Debian, Linux

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.