Always Display Filename with grep
The easiest way to accomplish this is if you have a relatively recent GNU version of grep
. Then the -H
version is available to you:
But if the -H
isn't available to you (I'm looking at your SunOS/Solaris) there's still hope, and it's nearly as easy:
By giving grep
/dev/null
(which it sees as a zero length file) in addition to the file you'd like to search grep
sees two files and will report back the filename of the file you'd like to search.