tar: directory

1 
1 6.10.1 Changing the Working Directory
1 -------------------------------------
1 
1 To change the working directory in the middle of a list of file names,
1 either on the command line or in a file specified using '--files-from'
1 ('-T'), use '--directory' ('-C').  This will change the working
1 directory to the specified directory after that point in the list.
1 
1 '--directory=DIRECTORY'
1 '-C DIRECTORY'
1      Changes the working directory in the middle of a command line.
1 
1    For example,
1 
1      $ tar -c -f jams.tar grape prune -C food cherry
1 
1 will place the files 'grape' and 'prune' from the current directory into
1 the archive 'jams.tar', followed by the file 'cherry' from the directory
1 'food'.  This option is especially useful when you have several widely
1 separated files that you want to store in the same archive.
1 
1    Note that the file 'cherry' is recorded in the archive under the
1 precise name 'cherry', _not_ 'food/cherry'.  Thus, the archive will
1 contain three files that all appear to have come from the same
1 directory; if the archive is extracted with plain 'tar --extract', all
1 three files will be written in the current directory.
1 
1    Contrast this with the command,
1 
1      $ tar -c -f jams.tar grape prune -C food red/cherry
1 
1 which records the third file in the archive under the name 'red/cherry'
1 so that, if the archive is extracted using 'tar --extract', the third
1 file will be written in a subdirectory named 'red'.
1 
1    You can use the '--directory' option to make the archive independent
1 of the original name of the directory holding the files.  The following
1 command places the files '/etc/passwd', '/etc/hosts', and '/lib/libc.a'
1 into the archive 'foo.tar':
1 
1      $ tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a
1 
1 However, the names of the archive members will be exactly what they were
1 on the command line: 'passwd', 'hosts', and 'libc.a'.  They will not
1 appear to be related by file name to the original directories where
1 those files were located.
1 
1    Note that '--directory' options are interpreted consecutively.  If
1 '--directory' specifies a relative file name, it is interpreted relative
1 to the then current directory, which might not be the same as the
1 original current working directory of 'tar', due to a previous
1 '--directory' option.
1 
1    When using '--files-from' (⇒files), you can put various 'tar'
1 options (including '-C') in the file list.  Notice, however, that in
1 this case the option and its argument may not be separated by
1 whitespace.  If you use short option, its argument must either follow
1 the option letter immediately, without any intervening whitespace, or
1 occupy the next line.  Otherwise, if you use long option, separate its
1 argument by an equal sign.
1 
1    For instance, the file list for the above example will be:
1 
1      -C/etc
1      passwd
1      hosts
1      --directory=/lib
1      libc.a
1 
1 To use it, you would invoke 'tar' as follows:
1 
1      $ tar -c -f foo.tar --files-from list
1 
1    The interpretation of options in file lists is disabled by
1 '--verbatim-files-from' and '--null' options.
1