Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find command ( with exclusion ) 3

Status
Not open for further replies.

superstarjpmc

Programmer
Jan 22, 2004
38
US
Hi,

I want to search a list of directories using a find command, by applying an exclusion.

say: find /tmp/ /var/ /opt/ -type d -print

If I want to exclude the directory and its subdirectories..(i.e.) I dont want my 'search criteria' to have /opt/varlog /opt/myfiles/, but still want to search all other subdirectories under /opt.

Can anyone lend a helping hand ?

regards
DJ
 
Perhaps filtering the output ?
... | egrep -v '/opt/(varlog|myfiles)/'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Can anyone suggest an option without 'grep'ing the output of 'find' ?
 
Why do you need another solution. The crux of the unix paradigm is to have many small efficient utilities that you string together to accomplish a complex task.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
find /tmp/ /var/ /opt/ -type d -print -type d -name varlog -prune -o -name myfiles -prune
 
It may be very inefficient to search certain directories. Use the -prune option of the find utility, e.g....

find /tmp /var /opt -type d ! \( -name varlog -o -name myfiles -prune \) -print
 
And what about /tmp/myfiles or /var/varlog ?
 
Excellent. Those who suffer from constipation say the same thing! ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top