From owner-freebsd-questions@FreeBSD.ORG Fri Feb 6 00:55:30 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 18B3C106564A for ; Fri, 6 Feb 2009 00:55:30 +0000 (UTC) (envelope-from cwhiteh@onetel.com) Received: from april.london.02.net (april.london.02.net [87.194.255.143]) by mx1.freebsd.org (Postfix) with ESMTP id A47DB8FC16 for ; Fri, 6 Feb 2009 00:55:29 +0000 (UTC) (envelope-from cwhiteh@onetel.com) Received: from [192.168.1.75] (93.97.24.219) by april.london.02.net (8.5.016.1) id 4967C92C0032C07A; Fri, 6 Feb 2009 00:55:27 +0000 Message-ID: <498B8A7F.2060906@onetel.com> Date: Fri, 06 Feb 2009 00:55:27 +0000 From: Chris Whitehouse User-Agent: Thunderbird 2.0.0.19 (X11/20090113) MIME-Version: 1.0 References: <332f78510902040635k6675a9b6u434879b42c66a579@mail.gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org, t-u-t 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: Fri, 06 Feb 2009 00:55:30 -0000 Jaime wrote: > On Wed, Feb 4, 2009 at 9:35 AM, t-u-t wrote: > 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} I think you should be able to do it with a combination of -prune and -delete (or -exec rm -rf {} \; ) on a find command. Substitute your other commands for rm -rf in the -exec above. I would give you a working example except I can't figure out the syntax for -prune. Examples from google don't seem to work in (my) FreeBSD. chrisw@pcbsd% find . . ./test.mov ./test.mpg ./dir1 ./dir1/file1 ./dir1/file2 ./file3 chrisw@pcbsd% find . -print . ./test.mov ./test.mpg ./dir1 ./dir1/file1 ./dir1/file2 ./file3 chrisw@pcbsd% find . -print -o -prune dir1 find: dir1: unknown option chrisw@pcbsd% find . -print -o -prune -name dir1 . ./test.mov ./test.mpg ./dir1 ./dir1/file1 ./dir1/file2 ./file3 chrisw@pcbsd% find . -print -o -name dir1 -prune . ./test.mov ./test.mpg ./dir1 ./dir1/file1 ./dir1/file2 ./file3 chrisw@pcbsd% find . -o -name dir1 -prune find: -o: no expression before -o chrisw@pcbsd% find . -name "*" -o -name dir1 -prune . ./test.mov ./test.mpg ./dir1 ./dir1/file1 ./dir1/file2 ./file3 chrisw@pcbsd% (Please don't tell me to read the man page, I have several times. Even Aeleen Frisch says it is impenetrable :P) Chris