Finding a string in a list of files, print file names

I'm interested in writing a report script using BASH that searches all of the files in a particular directory for a keyword and printing a list of files containing this string...

In fact this reporting script would have searches for multiple keywords, so I'm interested in making multiple searches that populate different groups and printing the different lists in one file formatted:

Keyword 1:
File
File
File

Keyword 2:
File
File
File

Would anyone have any advice for this type of script?

I was trying to use

grep keyword $DIRECTORY/*.log

, but I don't want the entire line printed - just the file name if it has the keyword present in the file.

man grep :

1 Like

Take a look at -l option in grep .

For example:
grep -l keyword $DIRECTORY/*.log

1 Like