From owner-freebsd-questions@FreeBSD.ORG Fri Feb 6 01:32:54 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 801F01065670 for ; Fri, 6 Feb 2009 01:32:54 +0000 (UTC) (envelope-from pprocacci@datapipe.com) Received: from fmailhost04.isp.att.net (fmailhost04.isp.att.net [207.115.11.54]) by mx1.freebsd.org (Postfix) with ESMTP id 696EC8FC12 for ; Fri, 6 Feb 2009 01:32:54 +0000 (UTC) (envelope-from pprocacci@datapipe.com) Received: from [10.5.21.122] (adsl-241-172-18.bna.bellsouth.net[74.241.172.18]) by isp.att.net (frfwmhc04) with ESMTP id <20090206013253H0400jtvkfe>; Fri, 6 Feb 2009 01:32:53 +0000 X-Originating-IP: [74.241.172.18] Message-ID: <498B9334.8090004@datapipe.com> Date: Thu, 05 Feb 2009 19:32:36 -0600 From: Paul Procacci User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: Chris Whitehouse References: <332f78510902040635k6675a9b6u434879b42c66a579@mail.gmail.com> <498B8A7F.2060906@onetel.com> In-Reply-To: <498B8A7F.2060906@onetel.com> 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 01:32:54 -0000 Chris Whitehouse wrote: > 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 > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org" find . \! -name blah -a \! -name blah2 -delete no?