1834685 Members
2196 Online
110069 Solutions
New Discussion

Re: The find command

 
SOLVED
Go to solution
Desiree Michael_1
Occasional Contributor

The find command

As an HP-UX user, to exclude a number of subdirectories I always used the "! ... -only" format, eg

"find / ! -path /user1 ! -path /user2 -only".

In Linux, this does not work. Instead I have tried to user the "-prune -or -print" format, but cannot successfully exclude more than one subdirectory, eg

"find / -path /user1 -prune -path /user2 -prune -or -print"

I feel I am not even close! Anyone got any ideas?
4 REPLIES 4
Donald Kok
Respected Contributor

Re: The find command

Hi Desiree,
This is not a real answer to your question, but might help you:

I let cron everynight perform a find / > /tmp/filelist
So I have a list of all files on my system. If I want to find a file, I just grep this filelist. This goes much faster than checking the hole tree. with grep -v , you can exclude some dirs.

I do f.i. cat /tmp/filelist | grep wanted_file | grep -v /bin | grep -v /usr/bin

Actioaly I made an alias findx, which is the first part of the example.

Hope this is some help
Donald
My systems are 100% Murphy Compliant. Guaranteed!!!
Stuart Browne
Honored Contributor
Solution

Re: The find command

find / \( -path /user1 -prune -o -path /user2 -prune \) -o -print

should do the trick..
One long-haired git at your service...
Desiree Michael_1
Occasional Contributor

Re: The find command

Thanks Stuart,

That did do the trick! Very helpful, thanks.

And thanks Donald, I may additionally use your idea.

This is the first time I have used this Linux forum, and I am very pleased with the quality of the posted responses. I expect you will be hearing more from me in the future!

Desiree
Balaji N
Honored Contributor

Re: The find command

Hi,
If what you want this is to locate files, there exists an utility called locate/slocate on most standard linux boxes which does the trick for you.

man locate for more details.

-balaji
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.