Chris Whitehouse wrote:
Jaime wrote:
On Wed, Feb 4, 2009 at 9:35 AM, t-u-t <marshc...@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.

chr...@pcbsd% find .
..
../test.mov
../test.mpg
../dir1
../dir1/file1
../dir1/file2
../file3
chr...@pcbsd% find . -print
..
../test.mov
../test.mpg
../dir1
../dir1/file1
../dir1/file2
../file3
chr...@pcbsd% find . -print -o -prune dir1
find: dir1: unknown option
chr...@pcbsd% find . -print -o -prune -name dir1
..
../test.mov
../test.mpg
../dir1
../dir1/file1
../dir1/file2
../file3
chr...@pcbsd% find . -print -o -name dir1 -prune
..
../test.mov
../test.mpg
../dir1
../dir1/file1
../dir1/file2
../file3
chr...@pcbsd% find . -o -name dir1 -prune
find: -o: no expression before -o
chr...@pcbsd% find . -name "*" -o -name dir1 -prune
..
../test.mov
../test.mpg
../dir1
../dir1/file1
../dir1/file2
../file3
chr...@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-unsubscr...@freebsd.org"

find . \! -name blah -a \! -name blah2 -delete

no?
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to