Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 06 Feb 2009 00:55:27 +0000
From:      Chris Whitehouse <cwhiteh@onetel.com>
Cc:        freebsd-questions@freebsd.org, t-u-t <marshc187@gmail.com>
Subject:   Re: shell commands - exclusion
Message-ID:  <498B8A7F.2060906@onetel.com>
In-Reply-To: <ae4324ed0902041905p4497c155u5d474533bbd5151f@mail.gmail.com>
References:  <332f78510902040635k6675a9b6u434879b42c66a579@mail.gmail.com> <ae4324ed0902041905p4497c155u5d474533bbd5151f@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Jaime wrote:
> On Wed, Feb 4, 2009 at 9:35 AM, t-u-t <marshc187@gmail.com> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?498B8A7F.2060906>