tar: extracting files
1
1 2.8.2 Extracting Specific Files
1 -------------------------------
1
1 To extract specific archive members, give their exact member names as
1 arguments, as printed by '--list' ('-t'). If you had mistakenly deleted
1 one of the files you had placed in the archive 'collection.tar' earlier
1 (say, 'blues'), you can extract it from the archive without changing the
1 archive's structure. Its contents will be identical to the original
1 file 'blues' that you deleted.
1
1 First, make sure you are in the 'practice' directory, and list the
1 files in the directory. Now, delete the file, 'blues', and list the
1 files in the directory again.
1
1 You can now extract the member 'blues' from the archive file
1 'collection.tar' like this:
1
1 $ tar --extract --file=collection.tar blues
1
1 If you list the files in the directory again, you will see that the file
1 'blues' has been restored, with its original permissions, data
1 modification times, and owner.(1) (These parameters will be identical
1 to those which the file had when you originally placed it in the
1 archive; any changes you may have made before deleting the file from the
1 file system, however, will _not_ have been made to the archive member.)
1 The archive file, 'collection.tar', is the same as it was before you
1 extracted 'blues'. You can confirm this by running 'tar' with '--list'
1 ('-t').
1
1 Remember that as with other operations, specifying the exact member
1 name is important (⇒failing commands, for more examples).
1
1 You can extract a file to standard output by combining the above
11 options with the '--to-stdout' ('-O') option (⇒Writing to Standard
Output).
1
1 If you give the '--verbose' option, then '--extract' will print the
1 names of the archive members as it extracts them.
1
1 ---------- Footnotes ----------
1
1 (1) This is only accidentally true, but not in general. Whereas
1 modification times are always restored, in most cases, one has to be
1 root for restoring the owner, and use a special option for restoring
1 permissions. Here, it just happens that the restoring user is also the
1 owner of the archived members, and that the current 'umask' is
1 compatible with original permissions.
1