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


GNU tar

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

6.4 Excluding Some Files

(This message will disappear, once this node revised.)

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.

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

Problems with Using the exclude Options  


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