Using Grep To Perform A Recursive Search For Text String

Home / Linux / Using Grep To Perform A Recursive Search For Text String
Using Grep To Perform A Recursive Search For Text String

I often find myself looking to a specific string of text within multiple directories and files. Grep makes this an easy task.

An almost daily use for me is searching a directory, (and all it’s sub-directories), for a string when working with some outdated theme or style on a web-server.

This example:

$ grep -r “search string” /path/to/directory

Grep will output a list of files that contain the search string and the “-r” switch ensures that grep will drill-down, (recursive search), into all subs.