Ubuntu – grep — list file name where match is found

command linegrep

I have a bunch of .html files in a directory. I want to look through each file and match a pattern (MD5). All of that is easy enough. The problem is I need to know what file the match was found in.

cat *.html | grep 75447A831E943724DD2DE9959E72EE31

Only returns the HTML page content where the match is found, but it doesn't tell me the file which it was found in. How can I get grep to show me the filename where my match is found?

Best Answer

grep -H 75447A831E943724DD2DE9959E72EE31 *.html

-H, --with-filename
              Print the file name for each match. This is
              the default when there is more than one file
              to search.
Related Question