www.delorie.com/gnu/docs/tar/tar_26.html   search  
 
Buy GNU books!


GNU tar

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.6.3 Extracting Files that are Directories

Extracting directories which are members of an archive is similar to extracting other files. The main difference to be aware of is that if the extracted directory has the same name as any directory already in the working directory, then files in the extracted directory will be placed into the directory of the same name. Likewise, if there are files in the pre-existing directory with the same names as the members which you extract, the files from the extracted archive will overwrite the files already in the working directory (and possible subdirectories). This will happen regardless of whether or not the files in the working directory were more recent than those extracted.

However, 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.

We can demonstrate how to use `--extract' to extract a directory file with an example. Change to the `practice' directory if you weren't there, and remove the files `folk' and `jazz'. Then, go back to the parent directory and extract the archive `music.tar'. You may either extract the entire archive, or you may extract only the files you just deleted. To extract the entire archive, don't give any file names as arguments after the archive name `music.tar'. To extract only the files you deleted, use the following command:

 
$ tar -xvf music.tar practice/folk practice/jazz

@quote-arg {need to show tar's response; used verbose above. also, here's a good place to demonstrate the -v -v thing. have to write that up (should be trivial, but i'm too tired!).}

Because you created the directory with `practice' as part of the file names of each of the files by archiving the `practice' directory as `practice', you must give `practice' as part of the file names when you extract those files from the archive.

@quote-arg {IMPORTANT! show the final structure, here. figure out what it will be.}


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 2003   by The Free Software Foundation     Updated Jun 2003  

Please take a moment to fill out this visitor survey
You can help support this site by visiting the advertisers that sponsor it! (only once each, though)