Subject: Re: Search all files for a string ?
To: =?iso-8859-1?q?Philip=20Christian?= <philipchristian2003@yahoo.co.uk>
From: Frederick Bruckman <fredb@immanent.net>
List: netbsd-help
Date: 01/28/2003 10:01:47
On Tue, 28 Jan 2003, Philip Christian wrote:

> Is there a tool that searches inside all files in a directory or a
> partition for a particular string of text ?

Simply put: "grep -r"

Additionally, the textproc/glimpse package can be used to create an
index, which may be faster for repeated operations, especially for a
whole partition.

For browsing directories of source code, I made this little shell
function:

ff() {
    less +/'*'"$1" $(find ${PWD} -type f ! -name tags ! -name Entries -printx | xargs grep -l "$1")
}

Copying and pasting into a Bourne-like shell defines a function "ff",
for "fast find" (even though it's not particularly fast!). "ff foo",
then, searches the current directory for "foo", "foo" being a regular
expresion. The pager is opened on any files found, with the searched
text highlighted. "n" or "{ESC}n" goes to the next highlighted item.

Frederick