GNU bug report logs - #35043
Is there a way to show file name once just before all the matches in the file?

Previous Next

Package: grep;

Reported by: Peng Yu <pengyu.ut <at> gmail.com>

Date: Fri, 29 Mar 2019 20:48:02 UTC

Severity: wishlist

To reply to this bug, email your comments to 35043 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-grep <at> gnu.org:
bug#35043; Package grep. (Fri, 29 Mar 2019 20:48:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Peng Yu <pengyu.ut <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Fri, 29 Mar 2019 20:48:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Peng Yu <pengyu.ut <at> gmail.com>
To: bug-grep <at> gnu.org
Subject: Is there a way to show file name once just before all the matches in
 the file?
Date: Fri, 29 Mar 2019 15:47:41 -0500
Hi,

By default, filenames are shown at the same lines of the matches (when
there are multiple files). But I'd like a filename only shown once
before all the matches in the given file. Is there an option to do so
with grep? Thanks.

-- 
Regards,
Peng




Information forwarded to bug-grep <at> gnu.org:
bug#35043; Package grep. (Sat, 30 Mar 2019 03:03:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Paul Jackson" <pj <at> usa.net>
To: bug-grep <at> gnu.org
Subject: Re: 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
[Message part 1 (text/plain, inline)]
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 <at> usa.net
[Message part 2 (text/html, inline)]

Severity set to 'wishlist' from 'normal' Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Thu, 02 Jan 2020 09:28:01 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 264 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.