Operating System - HP-UX
1822458 Members
2492 Online
109642 Solutions
New Discussion юеВ

How to stop find decending sub dirs

 

How to stop find decending sub dirs

What is the proper way of doing a
find in a dir without decending through
the sub directories?
I just can't get my head around the find man page.
I have used the _nasty_ workaround
find /archive/* -prune -type f -print
but it, of course, does not work with
lots of files (too many arguments)

Any clues?

Thanks
/Matt
5 REPLIES 5
James R. Ferguson
Acclaimed Contributor

Re: How to stop find decending sub dirs

Hi Matt:

By example:

# cd /tmp; find . -path "./*" -prune -name "*.log" -type f

...will return all files ending with ".log" in the /tmp directory but not those in subdirectories.

Regards!

...JRF...
Chris Wilshaw
Honored Contributor

Re: How to stop find decending sub dirs

Re: How to stop find decending sub dirs

Thanks for that James,
any chance you know of a generic
find command that works on more unixes
than hpux, (-path only works on hpux)
(I work on DEC/SUN as well as HP)

Cheers
/Matt
Rodney Hills
Honored Contributor

Re: How to stop find decending sub dirs

You could get a copy of gnu "find". Then you could run it on all your platforms.

It not only has -path, but also -maxdepth.

HTH

-- Rod Hills
There be dragons...
James R. Ferguson
Acclaimed Contributor

Re: How to stop find decending sub dirs

Hi (again) Matt:

No, I'm sorry I don't know of another form without '-path'.

Regards!

...JRF...