Previous: Extracting Archives from Untrusted Sources, Up: How to Extract Members from an Archive [Contents][Index]
Here are some sample commands you might try which will not work, and why they won’t work.
If you try to use this command,
$ tar -xvf music.tar folk jazz
you will get the following response:
tar: folk: Not found in archive tar: jazz: Not found in archive
This is because these files were not originally in the parent directory .., where the archive is located; they were in the practice directory, and their file names reflect this:
$ tar -tvf music.tar practice/blues practice/folk practice/jazz
Likewise, if you try to use this command,
$ tar -tvf music.tar folk jazz
you would get a similar response. Members with those names are not in the archive. You must use the correct member names, or wildcards, in order to extract the files from the archive.
If you have forgotten the correct names of the files in the archive, use tar --list --verbose to list them correctly.
To extract the member named practice/folk, you must specify
$ tar --extract --file=music.tar practice/folk
Notice also, that as explained above, the practice directory will be created, if it didn’t already exist. There are options that allow you to strip away a certain number of leading directory components (see Modifying File and Member Names). For example,
$ tar --extract --file=music.tar --strip-components=1 folk
will extract the file folk into the current working directory.