Advertisement
Tritonio

GNU Tar exclude issues

Sep 29th, 2018
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1.  
  2. [ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
  3. Problems with Using the exclude Options
  4. Some users find `exclude' options confusing. Here are some common pitfalls:
  5.  
  6. The main operating mode of tar does not act on a file name explicitly listed on the command line, if one of its file name components is excluded. In the example above, if you create an archive and exclude files that end with `*.o', but explicitly name the file `dir.o/foo' after all the options have been listed, `dir.o/foo' will be excluded from the archive.
  7. You can sometimes confuse the meanings of `--exclude' and `--exclude-from'. Be careful: use `--exclude' when files to be excluded are given as a pattern on the command line. Use `--exclude-from' to introduce the name of a file which contains a list of patterns, one per line; each of these patterns can exclude zero, one, or many files.
  8. When you use `--exclude=pattern', be sure to quote the pattern parameter, so GNU tar sees wildcard characters like `*'. If you do not do this, the shell might expand the `*' itself using files at hand, so tar might receive a list of files instead of one pattern, or none at all, making the command somewhat illegal. This might not correspond to what you want.
  9. For example, write:
  10.  
  11.  
  12. $ tar -c -f archive.tar --exclude '*.o' directory
  13. rather than:
  14.  
  15.  
  16. # Wrong!
  17. $ tar -c -f archive.tar --exclude *.o directory
  18. You must use use shell syntax, or globbing, rather than regexp syntax, when using exclude options in tar. If you try to use regexp syntax to describe files to be excluded, your command might fail.
  19. See The change in semantics must have occurred before 1.11, so I doubt if it is worth mentioning at all. Anyway, should at least specify in which version the semantics changed.
  20. In earlier versions of tar, what is now the `--exclude-from' option was called `--exclude' instead. Now, `--exclude' applies to patterns listed on the command line and `--exclude-from' applies to patterns listed in a file.
  21.  
  22. [ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
  23. This document was generated by Sergey Poznyakoff on December, 17 2017 using texi2html 1.76.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement