bsdtar '--exclude pattern' problems
Lowell Gilbert
freebsd-questions-local at be-well.ilk.org
Tue Nov 30 10:33:11 PST 2004
Karol Kwiatkowski <freebsd at orchid.homeunix.org> writes:
> Hello all,
>
> I upgraded 5.2.1 to 5.3 recently and I'm trying to run my cron scripts
> which use tar utility (which defaults to bsdtar(1) on 5.3) and I can't
> figure out how to use '--exclude pattern' with it. It seems I'm
> missing something obvious here or bsdtar(1) is happily ignoring
> --exclude option.
>
> my system:
> FreeBSD 5.3-RELEASE-p1 #4: Sat Nov 27 19:37:42 CET 2004
>
> here's what I try to run:
>
> orchid# /usr/bin/tar -czvf /home/root.backup/test.tar.gz -C /home . \
> --exclude "root.backup/*" --exclude "pub/*" --exclude "ncvs/*"
>
> I tried '-W exclude=pattern', too:
>
> orchid# /usr/bin/tar -czvf /home/root.backup/test.tar.gz -C /home . \
> -W exclude="root.backup/*" -W exclude="pub/*" -W exclude="ncvs/*"
>
> Both commands include all directories under /home. However using
> /usr/bin/gtar works as expected.
According to the tar(1) manual, the file parameters are supposed to
come after all of the option parameters. So instead of
> orchid# /usr/bin/tar -czvf /home/root.backup/test.tar.gz -C /home . \
> --exclude "root.backup/*" --exclude "pub/*" --exclude "ncvs/*"
I think you should have
> orchid# /usr/bin/tar -czvf /home/root.backup/test.tar.gz -C /home \
> --exclude "root.backup/*" --exclude "pub/*" --exclude "ncvs/*" .
which seems to do what you're expecting.
I don't have access to a copy of the POSIX spec, but I seem to recall
that it generally expects the options first. So that may be where the
behaviour originates.
Be well.
--
Lowell Gilbert, embedded/networking software engineer, Boston area
http://be-well.ilk.org/~lowell/
More information about the freebsd-questions
mailing list