How can we list only filenames after searching using grep?
When I use
grep -i -R "search keyword" folder
it'll list all the inline lines of code also.
From grep man page:
-L, --files-without-match Suppress normal output; instead print the name of each input file from which no output would normally have been printed. The scanning will stop on the first match.
-l, --files-with-matches Suppress normal output; instead print the name of each input file from which output would normally have been printed. The scanning will stop on the first match. (-l is specified by POSIX.)
For you, -l option would be helpful.
Use
grep -i -R -l "search keyword" location
to get the list of files which contain the keyword.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With