Subject: Re: bug#35043: Is there a way to show file name once just before all the matches in the file?

From: "Paul Jackson" <[email-masked]>
Date: Fri, 29 Mar 2019 23:01:48 -0400

The following awk command will do this (so long as filenames don't have ':' colon chars):

grep IP /etc/protocols /etc/services |
 awk -F: '
 $1 != fname { print $1 ":"; fname = $1; }
 { sub("^[^:]*:", ""); print; }
 '

-- 
 Paul Jackson
 [email-masked]