Finding files containing 'string'

Les Mikesell lesmikesell at gmail.com
Wed Feb 1 21:04:32 UTC 2006


On Wed, 2006-02-01 at 12:50, Paul wrote:
> >>
> >>
> >>> $ grep -i -r -l 'string' /place/to.start/searching
> >>
> >>
> >>
> >> Interesting gotcha with grep... doesn't look in files beginning with .
> >> when used like this.
> > 
> > 
> > Huh?
> > 
> > $ mkdir testdir
> > $ echo This is a test > testdir/.testfile
> > $ grep -i -r -l this testdir
> > testdir/.testfile
> > 
> 
> 	Methinks Andy is seeing the likes of
> 
> $ mkdir testdir
> $ echo This is a test > testdir/.testfile
> $ cd testdir
> $ grep -i -r -l this *
> grep: No match.

Errr, grep knows nothing about wildcard filename expansion.
That is done by the shell before starting grep with the
expanded list in its argument list.  The shell does not
expand filenames starting with . when you specify * as
a wildcard.  On the other hand, if you let grep recurse
from the current directory like:
grep -i -r -l this .
it would find it.

--
  Les Mikesell
   lesmikesell at gmail.com





More information about the users mailing list