Return to BSD News archive
Path: sserve!manuel!munnari.oz.au!spool.mu.edu!hri.com!ukma!darwin.sura.net!mips!pacbell.com!charon.amdahl.com!amdahl!JUTS!griffin!gab10 From: gab10@griffincd.amdahl.com (Gary A Browning) Newsgroups: comp.unix.bsd Subject: Re: The find not-operator Message-ID: <09hx024m1aXB01@JUTS.ccc.amdahl.com> Date: 16 Jul 92 01:12:57 GMT Article-I.D.: JUTS.09hx024m1aXB01 References: <BrG8o9.Eq6@ais.org> Sender: netnews@ccc.amdahl.com Organization: Amdahl Corporation, Sunnyvale CA Lines: 32 In article <BrG8o9.Eq6@ais.org>, lsloan@ais.org (Lance Sloan) writes: >I have several files in my home directory called testfile, I want to >delete all of them except for the one located in my bin subdirectory. As a >test, I tried to print the ones to be deleted first, but I'm having >problems using find's not-operator. Her's what I tried: > > find . -name 'testfile' -a \!-name 'bin/testfile' -print > >This causes various error messages depending on the location of "!". >My manual doesn't give an example of using "!". Maybe I'm doing the whole >thing wrong. Any help is greatly appreciated. I see two problems. A syntax error will occur because of the lack of space between "!" and "-name" (technically, you also do not need to espace the "!" and the "-a" is unnecessary but may add clarity. Other than that I do not get any syntax errors on either Sun's SunOS 4.1.1 or Amdahl's UTS 2.1.2. The second problem is that "-name" option deals with the basename of the file and not the form as printed by "-print". This is why the "-name testfile" can find the list of files called "testfile" in the first place. It is a filter of run across all of the files in the subtrees. One suggestion is to pipe the complete list of files to grep or sed and have one of them remove "./bin/testfile" from the list. -- Gary Browning | Exhilaration is that feeling you get just after a | great idea hits you, and just before you realize | what is wrong with it.