in reply to Re^3: text search in a file
in thread text search in a file

While we're on shell stuff, I've got to point out that that doesn't work if there's a lot of files below your current working directory. It'll fail with "argument list too long". Much better is:
$ find . -type f -exec grep -qi search_term {} \; -print
cheers

davis
Kids, you tried your hardest, and you failed miserably. The lesson is: Never try.

Replies are listed 'Best First'.
Re^5: text search in a file
by gellyfish (Monsignor) on Aug 11, 2005 at 09:34 UTC

    Even better if you want to optimize the number of sub-processes that get forked:

    find . -type f -print | xargs grep -qi

    /J\

Re^5: text search in a file
by kwaping (Priest) on Aug 11, 2005 at 15:41 UTC
    Thanks! That's a lot nicer to use than what I posted.

    Just FYI, Solaris' built-in grep doesn't like the q flag. This seems to work well:
    find search_path -type f -exec grep -li search_term {} \;
    Also, at least on Solaris, that -print causes double output.