How can I get grep to display the filename before the matching lines in its output?
grep
Try this little trick to coax grep into thinking it is dealing with multiple files, so that it displays the filename:
grep 'pattern' file /dev/null
To also get the line number:
grep -n 'pattern' file /dev/null
1.4m articles
1.4m replys
5 comments
57.0k users