[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Finding files containing 'string'



On Thu, 2006-02-02 at 16:38 +0000, Anne Wilson wrote:
> On Wednesday 01 Feb 2006 23:00, Daniel Vogel wrote:
> > > > I had two suggestions:
> > > > 1. gnome-search-tool
> > > > 2. find ./ -name "*" -exec grep "string" {} /dev/null \;
> > > >
> > > > Someone suggested even a better command solution than 2. above
> > > > but I can't remember what it is.
> > > > --
> > >
> > >find . -type f -print0 |xargs -0 grep "string"
> > >
> > >should work.
> >
> > ..err...my sugestion is much simple...
> >
> > grep -e <string> <files>
> >
> > the for example:
> > grep -e Daniel *.html
> >
> > will show me in wich file the line WITH the string "Daniel" will
> > appear. being more efficient, you can place another flag to show you
> > the exact line number.
> >
> > No need of cat, nor more to search on every file on a
> > directory...haven't tryed yet on a full root search.
> >
> > Hiope it helps.
> 
> The problem is that, while this looks simple, I'm trying to find all 
> config files that refer to my lan-name, and config files don't have a 
> specific extension.  In fact I can't think of any regular pattern to 
> their names.

To search ALL files, display the files with matching names AND the line
that matches:

	# find / -exec grep -iH pattern \{\} \;

Modify the find command to exclude directories you know you aren't
interested in.  For example to ignore any "mail" directories:

	# find / -path "*mail*" -prune -o -exec grep -iH pattern \{\} \;

----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer     rstevens vitalstream com -
- VitalStream, Inc.                       http://www.vitalstream.com -
-                                                                    -
-     There are only 10 kinds of people in the world -- those who    -
-                 understand binary and those who don't              -
----------------------------------------------------------------------


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]