Subject: Re: how to exclude a directory from find?

From: [email-masked]
Date: Thu, 12 Sep 96 09:24:41 cet

You wrote:
 >Subject: how to exclude a directory from find?
 >Author:  [email-masked] at cclink
 >Date:    11.09.96 21:33
 >
 >I'm trying to search for unused files, but I want to exclude a directory 
 >from the search. I tried
 >cd /scratch && find . -atime +7 -path ./var -prune -o -print
 >but it doesn't work. Any clues?
 >
 >Carlos
 
 If you're only interested in regular files, try adding the `-type f' to 
 the find command, e.g.,  
 
 $ cd /scratch && find . -type f -atime +7 -path ./var -prune -o 
 
 The -print flag is not really needed as is executed by default. 
 
 ----
 
 Certainly it would be nice to have something like:
 $ find . -type !d  
 to match files which are not directories, but I don't know if something 
 like that is possible for find. So if can take your question and rephrase 
 it: 
 
 Is there any kind of "logical not" affecting a flag in find? 
 Something similar to the `grep -v regexp' as opposed to `grep regexp'. 
 
 Answers are welcome.
 
 When I need something like  that, I always end up adding the flag -ls to 
 `find',  and piping to `grep -v pattern'. 
 
 Just to give you an idea of what I have in mind (I haven't tried this... 
 would you?)   
 
 $find . -ls | grep -v "dr???????? " 
 
 and if only the filename list is what you need, pipe the ouptut to `cut -c 
 column_number_here- '.
 
 As it is written above it will fail, as it filters out a filename with the 
 string `draconiano ', but you got the idea. right? 
 
 I repeat the above is a dirty/slow/inefficient/ugly/ and _imperfect_ 
 solution :-).
 
 I am guessing the ?s attempt to catch any of `the single characters r w x 
 s or - which may appear in the permission string written due to the `-ls' 
 flag to `find'. I am sure there might be better ways of specifying the 
 pattern to match (maybe grep'ing -v all the possibilities : `drwxrwxrwx ', 
 `drwxrwxrw- ', etc). The space at the end is important and the double 
 quoting too to avoid the shell to expand the patttern. 
 
 Of course, this may not be a solution for including in shell scripts, but 
 if you do it once in a while it might work.
 Cheers,
 
 Lazaro <[email-masked]>

PS. BTW, the man page for gnu find is the 1st one I recommend to learn 
thoroughly (I should do it again :-).

---

From: [email-masked] (Heiko Schlittermann)
Date: Thu, 12 Sep 1996 13:51:24 +0200 (MET DST)

[email-masked] wrote:
: 
:  
:  Certainly it would be nice to have something like:
:  $ find . -type !d  

find ! -type d

        or depending on your shell

find \! -type d

    Heiko
--
email : [email-masked] [email-masked] [email-masked]
pgp   : A1 7D F6 7B 69 73 48 35  E1 DE 21 A7 A8 9A 77 92 
finger: [email-masked]         [email-masked]

---

From: Juri Pakaste <[email-masked]>
Date: 12 Sep 1996 16:41:03 +0300

>>>>> "LS" == Lazaro Salem <[email-masked]> writes:

 LS>  Is there any kind of "logical not" affecting a flag in find?
 LS> Something similar to the `grep -v regexp' as opposed to `grep
 LS> regexp'.

There is. Try find . ! -type d etc. See the section on operators in
the gnu find man page.

-- 
Juri Pakaste/[email-masked]

---

From: Guy Maor <[email-masked]>
Date: Thu, 12 Sep 1996 11:39:16 -0500 (CDT)

>  Is there any kind of "logical not" affecting a flag in find? 

Yes, see the operators section in the find manpage.
Above would be
$ find . ! -type d

Guy