bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#35043: Is there a way to show file name once just before all the mat


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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]