Date: Wed, 4 Feb 2009 17:33:38 +0100 From: t-u-t <marshc187@gmail.com> To: freebsd-questions@freebsd.org Subject: Re: shell commands - exclusion Message-ID: <332f78510902040833h562ac10cte2e56188103aef78@mail.gmail.com> In-Reply-To: <20090204154814.GR75802@dan.emsphone.com> References: <332f78510902040635k6675a9b6u434879b42c66a579@mail.gmail.com> <20090204154814.GR75802@dan.emsphone.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Feb 4, 2009 at 4:48 PM, Dan Nelson <dnelson@allantgroup.com> wrote: > zsh has the ^ and ~ glob metacharacters that are enabled with you enable > EXTENDED_GLOB: > > ^x (Requires EXTENDED_GLOB to be set.) Matches anything except > the pattern x. This has a higher precedence than `/', so > `^foo/bar' will search directories in `.' except `./foo' for a > file named `bar'. > > x~y (Requires EXTENDED_GLOB to be set.) Match anything that > matches the pattern x but does not match y. This has lower > precedence than any operator except `|', so `*/*~foo/bar' will > search for all files in all directories in `.' and then > exclude `foo/bar' if there was such a match. Multiple > patterns can be excluded by `foo~bar~baz'. In the exclusion > pattern (y), `/' and `.' are not treated specially the way > they usually are in globbing. > > > and if there is, could the same be applied to other similar batch (?) > > operations, like pkg_delete -f "*" { except firefox3 wine thunderbird } > > etc.. > > That wildcard is expanded internally by pkg_delete using the C fnmatch() > function, which just does simple *?[] shell pattern matching. > > > i'm a bit new to the shell (took me a while to figure out *ls* and *ls | > > more*), but i can't find anything from google cuz i don't know what this > > would be called in the first place. > > > > otherwise is it better to protect them with chflags or other trickery? > > One workaround is to temporarily move the files you don't want to process > into another directory, then move them back when you're done. > > -- > thank you, i am interested in knowing how to do this stuff in general for simple operations, since like this workaround would work fine with file operations, but not for pkg_delete and other commands i can't think of right now. I was just wondering if there was a commonly used/known method or *switch* i could look into. however, form this post i get the impression that it is better( and worthwhile) to learn to do some proper scripting. say, prepare a list in a file, then pass each one to the command instead of "*". cheers
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?332f78510902040833h562ac10cte2e56188103aef78>