I have 9000 PHP files, most of which contain the text foo. I know that the file that I need has the text foo in a HEREDOC, but it is likely tens of lines away from either the beginning or end of the HEREDOC so grep's -A or -B options won’t help.
Is there any way to perform this search? Is there a better tool to use than grep?
This is on a CentOS 5.2 box, if relevant. Yes, I know that the OS is outdated!
This is pretty trivial with both
awkandsedbut onlyawkhas the ability to print both the filename and the line numberInput
Output