HomeUNIXExtract a Tar Archive or File

Extract a Tar Archive or File

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 the following:

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

Quinn McHenry
Quinn McHenry
Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

LATEST REVIEWS

Recent Comments

error: Content is protected !!