On Sun, Jun 2, 2013 at 3:44 PM, Peng Yu <pengyu...@gmail.com> 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.