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

3.4.4 Position-Sensitive Options

Some GNU tar options can be used multiple times in the same invocation and affect all arguments that appear after them. These are options that control how file names are selected and what kind of pattern matching is used.

The most obvious example is the `-C' option. It instructs tar to change to the directory given as its argument prior to processing the rest of command line (see section Changing the Working Directory). Thus, in the following command:

tar -c -f a.tar -C /etc passwd -C /var log spool

the file `passwd' will be searched in the directory `/etc', and files `log' and `spool' - in `/var'.

These options can also be used in a file list supplied with the `--files-from' (`-T') option (see section Reading Names from a File). In that case they affect all files (patterns) appearing in that file after them and remain in effect for any arguments processed after that file. For example, if the file `list.txt' contained:

-C src

and tar were invoked as follows:

tar -c -f a.tar -T list.txt Makefile

then the file `README' would be looked up in the current working directory, and files `main.c' and `Makefile' would be looked up in the directory `src'.

Many options can be prefixed with `--no-' to cancel the effect of the original option.

For example, the `--recursion' option controls whether to recurse in the subdirectories. It's counterpart `--no-recursion' disables this. Consider the command below. It will store in the archive the directory `/usr' with all files and directories that are located in it as well as any files and directories in `/var', without recursing into them(6):

tar -cf a.tar --recursion /usr --no-recursion /var/*

The following table summarizes all position-sensitive options.

`-C dir'

See section Changing the Working Directory.


See section NUL-Terminated File Names.


See input name quoting.


See verbatim-files-from.


See section Descending into Directories.


See anchored patterns.


See case-insensitive matches.


See section Controlling Pattern-Matching.


See section Controlling Pattern-Matching.


See section Excluding Some Files.


See section Excluding Some Files.

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

This document was generated on May, 16 2016 using texi2html 1.76.