What is the option for grep
that will allow me only to print the matching file and not the line within a file that matches the criteria?
239
votes
I typically only use this command when searching for files that call a specific function or method.
– Gearoid Murphy
use case (search and replace foo->bar in all files recursively): sed -i 's/foo/bar/' `grep -lR 'foo'`
– user323094
Possible duplicate of How can I use grep to show just filenames (no in-line matches) on linux?
– 7ochem
4 Answers
48
votes