From owner-freebsd-questions@FreeBSD.ORG Wed Feb 4 16:33:41 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1B22F1065672 for ; Wed, 4 Feb 2009 16:33:41 +0000 (UTC) (envelope-from marshc187@gmail.com) Received: from mail-ew0-f21.google.com (mail-ew0-f21.google.com [209.85.219.21]) by mx1.freebsd.org (Postfix) with ESMTP id 6F4348FC1C for ; Wed, 4 Feb 2009 16:33:40 +0000 (UTC) (envelope-from marshc187@gmail.com) Received: by ewy14 with SMTP id 14so4382498ewy.19 for ; Wed, 04 Feb 2009 08:33:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=2cf6yR0BLe5ldnhJv3WQi6ZpgHYi20o+DcKi8L9qOfU=; b=B0ZDPfNApvqAY0AQJZTjsEMVt7tWf2gM7HTQcmzdn3ccckk8sfdf+1GINyTh0bZ1jV IzPBMqzqpPD7hKR5xbYHzvKVGsy81rRj8athJDSO2DeW4Gff+wiBqubdJ9CpKrQZ5hGF OrEeELcGyZd/iXm4fmTefLo6gT7Il4hWcsFfY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=d9gxOjg8UehOci7Qmzz+Fae20gOoev6unzxmq5jcRULaKTEU2wt1gwhR+jryNnw2Mn u+JCNMBkEtKh69DFjj38ThF5QwCTkxHA/f2gtsB7DNEjljfNj5zxWhGVPPEn+kns3Pbh DQi3AP5s+Pl5aY5bnWRSBgKAjLrIWDW1ATK2k= MIME-Version: 1.0 Received: by 10.210.65.17 with SMTP id n17mr7013754eba.106.1233765219019; Wed, 04 Feb 2009 08:33:39 -0800 (PST) In-Reply-To: <20090204154814.GR75802@dan.emsphone.com> References: <332f78510902040635k6675a9b6u434879b42c66a579@mail.gmail.com> <20090204154814.GR75802@dan.emsphone.com> Date: Wed, 4 Feb 2009 17:33:38 +0100 Message-ID: <332f78510902040833h562ac10cte2e56188103aef78@mail.gmail.com> From: t-u-t To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Re: shell commands - exclusion X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Feb 2009 16:33:41 -0000 On Wed, Feb 4, 2009 at 4:48 PM, Dan Nelson 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