|
From: | Paul Jackson |
Subject: | bug#35043: Is there a way to show file name once just before all the matches in the file? |
Date: | Fri, 29 Mar 2019 23:01:48 -0400 |
User-agent: | Cyrus-JMAP/3.1.6-329-gf4aae99-fmstable-20190329v1 |
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 address@hidden
[Prev in Thread] | Current Thread | [Next in Thread] |