tar: extract dir
1
1 2.8.3 Extracting Files that are Directories
1 -------------------------------------------
1
1 Extracting directories which are members of an archive is similar to
1 extracting other files. The main difference to be aware of is that if
1 the extracted directory has the same name as any directory already in
1 the working directory, then files in the extracted directory will be
1 placed into the directory of the same name. Likewise, if there are
1 files in the pre-existing directory with the same names as the members
1 which you extract, the files from the extracted archive will replace the
1 files already in the working directory (and possible subdirectories).
1 This will happen regardless of whether or not the files in the working
1 directory were more recent than those extracted (there exist, however,
1 special options that alter this behavior ⇒Writing).
1
1 However, if a file was stored with a directory name as part of its
1 file name, and that directory does not exist under the working directory
1 when the file is extracted, 'tar' will create the directory.
1
1 We can demonstrate how to use '--extract' to extract a directory file
1 with an example. Change to the 'practice' directory if you weren't
1 there, and remove the files 'folk' and 'jazz'. Then, go back to the
1 parent directory and extract the archive 'music.tar'. You may either
1 extract the entire archive, or you may extract only the files you just
1 deleted. To extract the entire archive, don't give any file names as
1 arguments after the archive name 'music.tar'. To extract only the files
1 you deleted, use the following command:
1
1 $ tar -xvf music.tar practice/folk practice/jazz
1 practice/folk
1 practice/jazz
1
1 If you were to specify two '--verbose' ('-v') options, 'tar' would have
1 displayed more detail about the extracted files, as shown in the example
1 below:
1
1 $ tar -xvvf music.tar practice/folk practice/jazz
1 -rw-r--r-- me/user 28 1996-10-18 16:31 practice/jazz
1 -rw-r--r-- me/user 20 1996-09-23 16:44 practice/folk
1
1 Because you created the directory with 'practice' as part of the file
1 names of each of the files by archiving the 'practice' directory as
1 'practice', you must give 'practice' as part of the file names when you
1 extract those files from the archive.
1