Software >> OS >> Unix >> Linux >> commands >> grep >> how to use grep to search for a keyword and display the filename, line number and the matching line text

Example

# grep -Hin ServerName /etc/httpd/conf/httpd.conf 
/etc/httpd/conf/httpd.conf:89:# ServerName gives the name and port that the server uses to identify itself.
/etc/httpd/conf/httpd.conf:95:#ServerName www.example.com:80
/etc/httpd/conf/httpd.conf:96:ServerName testweb.ourexample.com