Go to the first, previous, next, last section, table of contents.


Excluding Some Files

@UNREVISED

To avoid operating on files whose names match a particular pattern, use the --exclude=pattern or --exclude-from=file-of-patterns (-X file-of-patterns) options.

--exclude=pattern
Causes tar to ignore files that match the pattern.

The --exclude=pattern option will prevent any file or member which matches the shell wildcards (pattern) from being operated on (pattern can be a single file name or a more complex expression). For example, if you want to create an archive with all the contents of `/tmp' except the file `/tmp/foo', you can use the command `tar --create --file=arch.tar --exclude=foo'. You may give multiple `--exclude' options.

--exclude-from=file
-X file
Causes tar to ignore files that match the patterns listed in file.

Use the `--exclude-from=file-of-patterns' option to read a list of shell wildcards, one per line, from file; tar will ignore files matching those regular expressions. Thus if tar is called as `tar -c -X foo .' and the file `foo' contains a single line `*.o', no files whose names end in `.o' will be added to the archive.

@FIXME{do the exclude options files need to have stuff separated by newlines the same as the files-from option does?}


Go to the first, previous, next, last section, table of contents.