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.
Ubuntu – 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
- Ubuntu – 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).