Extract a tar archive or file

Home -> UNIX

32987 views

From the computer of: qmchenry (337 recipes)
Created: Jul 12, 2006


Add a comment

Add to:
Add to stumbleuponAdd to del.icio.usDigg itAdd to FURL

The tar file is the long-time champion of archiving files and even directories of information into a single archive file. However, the first time you face a tar file, it will completely clam up and will not tell you what to do with it. Extracting the contents of a tar file is simple (once you know how).

A tar file is extracted (and created) with the easy-to-remember application tar. While the name is simple, the syntax is a little different than normal UNIX commands. To extract the contents of the file archive.tar, use:

tar xf archive.tar


The x in xf means extract the contents of the archive. The f in xf tells tar to use the next parameter as the filename of the archive. This comes from tar's history as a tape archiving application (the name tar comes from tape archive). By default, tar wants to read or write to a tape drive, thus the f parameter.

Another couple of nice parameters to know are t and v. The t parameter is used in place of x to list a table of contents of the archive.

tar tf archive.tar


The v parameter can be used with x to list each file in the archive while extracting them.

tar xvf archive.tar

Subscribe to the Tech-Recipes Newsletter

You can get tips like this delivered in your email every week!

Enter your Email

We will never, ever sell your email address or spam you.





Related recipes:

  Decompress and extract a tgz or tar.gz archive in a single step
  Extract a bz2 or bzip2 file
  Extract a gzip compressed tar archive in Linux
  Create a TAR archive of a directory
  Create a symbolic link in UNIX
  Select an arbitrary column of text in UNIX
  Validate information from a Solaris flash archive
  Create a local Solaris flash archive
  Tar and compress a file in one step
  creating a solaris 8 flash archive boot disk

 

Sponsored links

 

Login

Nickname

Password

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.