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
pj@usa.net