Grep and --exclude? or, finding a text string that might be anywhere

Bill Campbell freebsd at
Sun Apr 22 05:11:47 UTC 2007

On Sat, Apr 21, 2007, L Goodwin wrote:
>Oliver, the error is due to incorrect syntax ("-e" flag omitted). Try this:
>grep -R /usr -e "any2dvd"
>L Goodwin
>Oliver Iberien <odilist at> wrote: I need to find a reference to an obscure delete port that is in some file 
>somewhere (in /usr/ports/? somewhere in /usr?) as it is messing up make and, 
>among other things, preventing me from running the gnome upgrade script. So, 
>I do what little I know to do:
>grep -R /usr/* "any2dvd"
>This brings out a few valid discoveries (mostly in mailfiles when I posted 
>about this) and lots of "operation not supported" and "No such file or 
>directory" errors before grep spits out a "memory exhausted" error. If I 
>could at least stop it from looking at */tmp/* and ~/.kde it might have a 
>chance to get somewhere, but I can't figure out how --exclude 
>or --exclude-dir work, despite googling over and over for examples. Can this 
>be made to work? Or is there a better way?

I generally use find, xargs, and grep for things like this:

find /usr -type f | xargs grep -l 'any2dvd'


find /usr -type f | egrep -v '/.kde|/tmp/' | xargs grep -l 'any2dvd'

INTERNET:   bill at Celestial.COM  Bill Campbell; Celestial Software LLC
URL:  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676

``If we got one-tenth of what was promised to us in these acceptance
speeches there wouldn't be any inducement to go to heaven.''
    Will Rogers

More information about the freebsd-questions mailing list