Ramin Hossaini

Search through files for a string (Linux)

Nov
04

To search a directory recursively for specific text or a string, use:

find . -exec grep "string to find" '{}' \; -print

One Response to Search through files for a string (Linux)

  1. When searching for something very specific like an error code, I use what you’ve describe here.

    When searching for a term where I’m simply guessing might be relevant, I typically use the -l flag with grep to just print the file name rather than the match. Usually the path or name gives me a good idea about whether the file is relevant. I’ll pick the more relevant files to use grep for searches inside.

Leave a Reply

Your email address will not be published. Required fields are marked *