I want to find all files which contain a specific string of text. The grep
command works, but I don't know how to use it for every directory (I can only do it for my current directory). I tried reading man grep
, but it didn't yield any help.
Command Line – How to Use ‘grep’ Command to Find Text Including Subdirectories
command linegrep
Related Question
- Ubuntu – How to use grep to find all the zip files in a directory
- Ubuntu – Grep through subdirectories
- Ubuntu – Find text file containing a given text ignoring new lines and spaces
- Ubuntu – grep command for a text file in multiple directories
- Grep – How to Use Grep on All Files Non-Recursively in a Directory
Best Answer
It would be better to use
where
-r
(or--recursive
) option is used to traverse also all sub-directories of/path
, whereas-l
(or--files-with-matches
) option is used to only print filenames of matching files, and not the matching lines (this could also improve the speed, given thatgrep
stop reading a file at first match with this option).