On Wed, 6 Jul 2005, C. Bensend wrote:

> Hey folks,
> 
>    OK, I think I've got the dunce hat on today, and I'm about to
> go crazy with this one.
> 
>    I have a script on an OpenBSD 3.7-STABLE machine that does
> a find in a directory, and uses rm to remove files older than
> two days (where RETAIN = "+2") :
> 
> find /path/to/dir -type f -name \*.gz -mtime ${RETAIN} -exec rm {} \;
> 
>    This directory has a subdir (a .ssh), and no matter what I
> do, I cannot get find to NOT recurse into this subdirectory.  I've
> tried using -path, ! -path, -maxdepth 0|1, and none of them seem
> to do what I want.  I only want find to examine the /path/to/dir
> directory, and not any subdirs.
> 
>    I've been through the man page so many times, I can just about
> recite it.  Am I just missing something, or is this not possible?
> I'm guessing it's the former and I've just stared at it too long to
> see the obvious.

Something like this should work (compare some of th examples of the man
page):

find /path/to/dir -name .ssh -type d -prune -or \
        -type f -name \*.gz -mtime ${RETAIN} -exec rm {} \;

        -Otto

Reply via email to