1834926 Members
2680 Online
110071 Solutions
New Discussion

HP UNIX Find Comamnd

 
J_170
Occasional Advisor

HP UNIX Find Comamnd

Hi,
What is the command line arguement that will only allow find go 1 level deep?

I have try -depth, it does not work.

6 REPLIES 6
Simon Hargrave
Honored Contributor

Re: HP UNIX Find Comamnd

There's no need to use find for one level deep.

For example, you can achieve the hypothetical find command: -

find . -name "*fish*" -mysticaldepth 1

with

ls -d *fish* */*fish*
Prashant Zanwar_4
Respected Contributor

Re: HP UNIX Find Comamnd

find . -name -xdev -exec command {} \;

-xdev will cause not to cross the FS boundries..you can also check prune option in find man page..

Cheers
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
Geoff Wild
Honored Contributor

Re: HP UNIX Find Comamnd

I agree with Simon - why find when you can grep?

-xdev will avoid any mounted file systems below the intial path...

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
J_170
Occasional Advisor

Re: HP UNIX Find Comamnd

Thank you for all your reply.
I am using the -mtime option to remove old files. But, I do not want it to go more than just that directory.
I have try -depth, -prune, -fonely, -only, etc. None of them do what I need.

Here is my command:
/bin/find . -type f -mtime +7 -exec rm {} \;
Rodney Hills
Honored Contributor

Re: HP UNIX Find Comamnd

Apart from gnu find (which has a -level option), you could do use the following-

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

The -path option will restrict it to 1 level. For 2 levels, -path "./*/*".

HTH

-- Rod Hills
There be dragons...
Mark Greene_1
Honored Contributor

Re: HP UNIX Find Comamnd

You said you tried -prune and -depth. These are independant options, and neither will work when specified together. Did you try using just -prune? That should take care of what you need. Also, in my experience it is better to be in the directory and use the "." directory reference than not to be in the dir and use the path name.

mark
the future will be a lot like now, only later