Go to the previous, next section.

Extracting Archive Members

(This message will disappear, once this node revised.)

Use `--extract' (`-x') or `--get' to extract members from an archive. For each member named (or for the entire archive if no members are named) on the command line--or with `--files-from=file-of-names' (`-T file-of-names')---the a file is created with the contents of the archive member. The name of the file is the same as the member name.

Various options cause tar to extract more than just file contents, such as the owner, the permissions, the modification date, and so forth.

FIXME: begin
The `--same-permissions' (`-p') or `--preserve-permissions' options cause tar to cause the new file to have the same permissions as the original file did when it was placed in the archive. Without this option, the current umask is used to affect the permissions.

When extrating, tar normally sets the modification time of the file to the value recorded in the archive. The `--modification-time' (`-m') option causes tar to omit doing this.

FIXME: end

To read archive members from the archive and write them into the file system, use `--extract' (`-x'). The archive itself is left unchanged.

If you do not specify the files to extract, tar extracts all the files in the archive. If you specify the name of a directory as a file name argument, tar will extract all files which have been stored as part of that directory. If a file was stored with a directory name as part of its file name, and that directory does not exist under the working directory when the file is extracted, tar will create the directory.

FIXME: xref Selecting Archive
Members
, for information on specifying files to extract.

The following example shows the extraction of the archive `stooges' into an empty directory:

tar --extract --file=stooges

Generating a listing of the directory (`ls') produces:

larry
moe
shemp
marx

The subdirectory `marx' contains the files `julius', `alexander' and `karl'.

If you wanted to just extract the files in the subdirectory `marx', you could specify that directory as a file name argument in conjunction with the `--extract' (`-x') operation:

tar --extract --file=stooges marx

Warning: Extraction can overwrite files in the file system. To avoid losing files in the file system when extracting files from the archive with the same name, use the `--keep-old-files' (`-k') option (
FIXME: pxref File Writing Options
).

If the archive was created using `--block-size=512-size' (`-b 512-size'), `--compress' (`-Z') or `--multi-volume' (`-M'), you must specify those format options again when extracting files from the archive (

FIXME: pxref Format Variations
).

Go to the previous, next section.