Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Oct 2003 05:52:02 -0400
From:      Richard Coleman <richardcoleman@mindspring.com>
To:        jason@dictos.com
Cc:        questions@freebsd.org
Subject:   Re: Searching contents of files
Message-ID:  <3F97A4C2.1080001@mindspring.com>
In-Reply-To: <200310211158.11136.jason@dictos.com>
References:  <200310211158.11136.jason@dictos.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Here is the classical way to do a recursive grep.

For csh/tcsh, define the alias

    alias rgrep 'find . -type f -print | xargs egrep -i \!* /dev/null'

For bash/zsh, define the shell function

    rgrep() { find . -type f -print | xargs egrep -i $1 /dev/null}

There are several variations of these that will work.  But these are 
both fast and portable, and should work on virtually any flavor of unix.

Richard Coleman
richardcoleman@mindspring.com

jason dictos wrote:

> Hi All,
> 
>    I've always used grep text /*/*/* to recursivly search directories for 
> files with the specified text string in them, however this method doesn't 
> always work very well (sometimes it bails out halfway through with error 
> "Argument list too long"). 
> 
> Is there a more effective way to search the contents of files?





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3F97A4C2.1080001>