From owner-freebsd-questions@FreeBSD.ORG Wed Feb 4 15:27:12 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 580DC106564A for ; Wed, 4 Feb 2009 15:27:12 +0000 (UTC) (envelope-from lars@larseighner.com) Received: from mail.team1internet.com (mail.team1internet.com [216.110.13.10]) by mx1.freebsd.org (Postfix) with ESMTP id 29ECD8FC16 for ; Wed, 4 Feb 2009 15:27:12 +0000 (UTC) (envelope-from lars@larseighner.com) Received: by mail.team1internet.com (Postfix, from userid 12346) id 61E2F16B650; Wed, 4 Feb 2009 09:27:11 -0600 (CST) Received: from larseighner.com (unknown [216.110.13.97]) by mail.team1internet.com (Postfix) with SMTP id AD24D16B709; Wed, 4 Feb 2009 09:27:09 -0600 (CST) Received: by larseighner.com (nbSMTP-1.00) for uid 1001 lars@larseighner.com; Wed, 4 Feb 2009 09:26:12 -0600 (CST) Date: Wed, 4 Feb 2009 09:26:10 -0600 (CST) From: Lars Eighner X-X-Sender: lars@debranded.6dollardialup.com To: t-u-t In-Reply-To: <332f78510902040635k6675a9b6u434879b42c66a579@mail.gmail.com> Message-ID: <20090204091459.G16842@qroenaqrq.6qbyyneqvnyhc.pbz> References: <332f78510902040635k6675a9b6u434879b42c66a579@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Sanitizer: Anomy and SpamAssassin mail filter - see http://www.6dollardialup.com/support/spaminfo.html Cc: freebsd-questions@freebsd.org 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 15:27:12 -0000 On Wed, 4 Feb 2009, t-u-t wrote: > hi, i don't know if this is a freak question, but i was looking around to > see if this is possible, and what the convention would be. > > if i have say one (or even two) single file/directories among many others, > and i want to perform any said function like cp, mv, rm, etc.. , to all > other files except that one or two, is there a way to do that in a single > command? > e.g > rm -r * {-except foo1 foo15} In general this is not possible. A few commands have exclusion options, but not many. Some shells have ways of managing glob exclusion (it's the shell that expands wildcard patterns). Setting GLOBIGNORE works in BASH, whether something similar works in others, you will have to investigate yourself. But that isn't one line as you have to set GLOBIGNORE. BASH also has an extended pattern matching option which includes negation, so you might want to look into that. > and if there is, could the same be applied to other similar batch (?) > operations, like pkg_delete -f "*" { except firefox3 wine thunderbird } > etc.. pkg_delete can take regular expression arguments (see -x). Perhaps you can devise one that will do the trick. Beware, however: it can take multiple regular expressions and deletes package which match ANY (not all) of them. > 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. Shell globbing is the operation by which the shell expands wildcards and finds matches. What you want to do exclude things from shell globbing. > otherwise is it better to protect them with chflags or other trickery? watch out anything involving recursion --- things can happen that you don't expect unless you really know what you are doing. -- Lars Eighner http://www.larseighner.com/index.html 8800 N IH35 APT 1191 AUSTIN TX 78753-5266