From Bugzilla Helper: User-Agent: Mozilla/4.77 [en] (X11; U; Linux 2.4.3-13 i686) Description of problem: It is not clear anywhere as to what is the correct syntax for the --exclude option Can it be used more than once in a command line? Which is the proper syntax ? 1 tar -czf --exclude=/etc/somedir*' /etc or 2 tar -czf --exclude='/etc/somedir*' /etc or 3 tar -czf --exclude /etc/somedir* /etc or 4 tar -czf --exclude '/etc/somedir*' /etc Atleast # 3 appears not to work? I would be happy to assist who ever is maintaining the docs with this issue - provide me the man page and I will test the syntax. Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: tar -zcf --exclude /etc/somedir* /etc 3. Actual Results: returns errors Expected Results: would work as in man page Additional info: I would be happy to assist who ever is maintaining the docs with this issue - provide me the new man page and I will test the syntax.
The correct usage is tar czf foo.tar /etc --exclude 'pattern' e.g. tar cjf foo.tar.bz2 /etc --exclude 'passwd*' would back up your /etc, but not passwd, passwd-, passwd.old and whatever else you have. I've taken the documentation issue up with the base package maintainer; waiting for his response.
I've just met this myself on RH 7.2, tar 1.13.19. It didn't help that I was mixing and matching old-style single letter options and longopts in the first few runs. Some suggestions for docs improvements: man tar should mention that it is far safer to stick to *either* longoptions, *or* the ones with hyphens, *or* the old ones :) (Ow.) I am not sure that info explicitly says this, but it's abundantly clear in the examples of "what these do" from it. Why does man tar refer to "--longopt foo" and info tar to "--longopt=foo"? Is the = necessary? Finally, this did not do what I expected: tar --create --verbose --multivolume --exclude /home/hobbit/ogg --file /dev/st0 /etc /home I expected this to "tar cvf" /etc and /home onto the tape, with the exception of the ogg collection. It put /etc and /home onto the tape, but it did not exclude /home/hobbit/ogg. If this has something to do with -P and leading slashes being dropped from the --exclude file as well as from the files being archived, I *really* think this needs putting in the man page and the info page. If it was the lack of the equals sign, the man page needs fixing. If a plain filename won't work, that definitely needs mentioning! (For anyone who queries bugzilla and wants an answer to something similar, I used --exclude *.ogg in the end. And --exclude *.rpm, so to the original questioner: yes, it can be used twice in the same command line.) I gather the man page is RH's (or Debian's) and the info file is GNU's. Can I request that "please give info examples clarifying --exclude and its syntax" gets passed upstream, or should I head for the spamtrap that is bug-gnu-utils myself? Oh -- and on RH when you type info tar, you start at the node beginning "now that we have learned the three most common options in the tutorial..". I think it should start at the beginning, before the tutorial! info is somewhat difficult to negotiate for some people (me), and finding the start of the thing took a while. Sorry this is so long, but if you're talking to the maintainers anyway, perhaps it's a good time to mention it.
fixed in devel and FC4-update. tar-1.15.1-10.