Reputation:
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.
Upvotes: 4
Views: 3220
Reputation: 3223
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.
Upvotes: 4
Reputation: 674
Use
grep -i -R -l "search keyword" location
to get the list of files which contain the keyword.
Upvotes: 3