bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trim directory to search?


From: James Youngman
Subject: Re: Trim directory to search?
Date: Sun, 2 Jun 2013 22:11:50 +0100

On Sun, Jun 2, 2013 at 3:44 PM, Peng Yu <address@hidden> wrote:
> Hi,
>
> I don't want to let find search directories with a file .ignore (i.e.,
> anything in the directory (including the subdirectories) is ignored).
> Is there an efficient way to customize find in this way? (I can think
> of an simple way---recursively call "find" with maxdepth 1 and not go
> into directories with .ignore. But this is not efficient.) Thanks.

find .  \( -type d -exec test -e {}/.ignore \; -prune \) -o ....

will do something like what you want.   But, again, it's not
efficient, since it performs one fork/exec per subdirectory.   A more
efficient way might be to build a -prune expression with the output of
'locate .ignore'.  But this will only work well if you only use this
technique for find expressions where the start points are absolute
pathnames.

Other options depend a bit on how you identify which directories you
put .ignore files in, and whether you can change anything else about
them.    That is, you could build a list of ignored directories (as a
text file) instead of putting .ignore flagfiles in them.   Or change
the permissions on the directory (i.e. chgrp ignore somedir; chown g=
somedir; then run find as with the effective GID set to ignore).

James.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]