Searching for a specific text or pattern across multiple files can be completed using
grep to search file contents
grep provides searching functionality out-of-the-box:
Here are a breakdown of the
-nfor line number
-wfor matching the whole word
-eis the pattern used for searching
The command will output the file names and text containing the pattern. If the goal is simply to display the filenames themselves, add the
If binary files need to be omitted, add the
In addition, the
--exclude-dir may be used in combination.
dir2, find all
p in them.