Operating System - HP-UX
1833150 Members
3518 Online
110051 Solutions
New Discussion

Re: How to restrict search depth for 'find'

 
SOLVED
Go to solution
Gary Yu
Super Advisor

How to restrict search depth for 'find'

Hi all,

I was wondering is there any way to restrict the depth in a directory tree when using find command, say, how can I search files only in the current directory in stead of going down all the way to the the bottom of the directory tree?

I read the man page of find command, seemed no such parameters, any idea?

thanks,

Gary
4 REPLIES 4
Rodney Hills
Honored Contributor

Re: How to restrict search depth for 'find'

find ./* -prune

will only do one level.

find ./*/* -prune

will do two levels.

Hope this helps.

-- Rod Hills
There be dragons...
Rodney Hills
Honored Contributor
Solution

Re: How to restrict search depth for 'find'

Please disregard previous example.

Should be -

find . -path "./*" -prune -print

-- Rod Hills
There be dragons...
Gary Yu
Super Advisor

Re: How to restrict search depth for 'find'

Thanks Rod, it works, I must had a misunderstanding of the parameter "-prune". thanks again for the prompt response.

Gary
Carlos Fernandez Riera
Honored Contributor

Re: How to restrict search depth for 'find'

HI Rod:

I was trying it just few days ago and i think it dont work for me ( maybe quotes).

Every way, you deserve your hat, ( congrats).
unsupported