From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 29 16:47:55 2019 Received: (at submit) by debbugs.gnu.org; 29 Mar 2019 20:47:55 +0000 Received: from localhost ([127.0.0.1]:36052 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h9yPq-0002YC-Pi for submit@debbugs.gnu.org; Fri, 29 Mar 2019 16:47:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33551) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h9yPo-0002Xz-QG for submit@debbugs.gnu.org; Fri, 29 Mar 2019 16:47:53 -0400 Received: from lists.gnu.org ([209.51.188.17]:49729) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h9yPj-0003FF-Je for submit@debbugs.gnu.org; Fri, 29 Mar 2019 16:47:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9yPi-0003pI-Nd for bug-grep@gnu.org; Fri, 29 Mar 2019 16:47:47 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h9yPg-0003EH-Pj for bug-grep@gnu.org; Fri, 29 Mar 2019 16:47:46 -0400 Received: from mail-it1-x12b.google.com ([2607:f8b0:4864:20::12b]:54911) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h9yPg-0003D9-IG for bug-grep@gnu.org; Fri, 29 Mar 2019 16:47:44 -0400 Received: by mail-it1-x12b.google.com with SMTP id w18so5907574itj.4 for ; Fri, 29 Mar 2019 13:47:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=cp+BiLX/3O7v9O/qzPsFIN3LoULM4/EypSbck0n6zeY=; b=G4QuQgAYgx6tEVPDdB2gOCG+F302nUuUp+MM6toaBzN77QcgxyxREFClXaSllSUvbj 3pjERBOivav2F/OBBgh5M/tUukjWftzkXxNuU7VzL8k/chI7YHc6Yk3T42NWn1pofC3a /+faLwTCFTm3NCJQYVc8tJKRYVIcyOUgZudYQXBUCWDvM2b1aGEijX4eXxKkX0UOejrz UJsOVG+BP6E0qxqXWsUx0/89PVguYuJy2AoGbUsmtCEj9AmrBjrAsu6dX9HSMX58RQC1 4nerg9j3uUZBCI2Vf2nLAbgTJwpQBb4DXoNTcIXsY4xPWmwWRQnLJIG/ycL/ONAeZUCR Q2zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=cp+BiLX/3O7v9O/qzPsFIN3LoULM4/EypSbck0n6zeY=; b=No65TZ7akrgYTdVIAQBKD+oILa7p4CHxTZ8YbEpB7EMvl714FsAU8vKZv2SmY0tkmy 1l3F7Q7v/3U9aglWBihVVWojSzCN4a9pLVGJJvJ0sjGT80n+4XOj7bb7ugsHoVE+ItFE nfQNe2DVL0eHqMmMP9lL2FeJ5BbZfhxQUvgcbQYcAgQtJj1Zeh58AWqjpWNNQis/fnC4 P9/O/sUC/ZVsDRH3DNN9LxFicOMnTXr7osLQCJg5lWRL/Dqo2jEg0HnCPktJ+1mzG00m f9jTBipLP8Y8s05McNBKZ7XEH+nwytMGziSizM1u56FyA1W+LvhUXwD1ZCpe7t2yf9Xb 3TRQ== X-Gm-Message-State: APjAAAXexxUlh5VVdoTvfJj7jdd05Ya2pWDGSd1sanVkLdfmMl/64t9D ZmD4C6ton8dJ+Yidc1NfGZlfMNPq9tIp0JjwO7dpZw== X-Google-Smtp-Source: APXvYqy9yi+vfxMKp2PPcUCWhqRsneEq8tLCIVx16rWXJxVnWexkR5dDG/r1nSvcpt7UZ1fk1hzTASG0dbeEhs8WO/8= X-Received: by 2002:a24:57c1:: with SMTP id u184mr6209313ita.38.1553892462755; Fri, 29 Mar 2019 13:47:42 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a5e:9707:0:0:0:0:0 with HTTP; Fri, 29 Mar 2019 13:47:41 -0700 (PDT) From: Peng Yu Date: Fri, 29 Mar 2019 15:47:41 -0500 Message-ID: Subject: Is there a way to show file name once just before all the matches in the file? To: bug-grep@gnu.org Content-Type: text/plain; charset="UTF-8" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::12b X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) 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 From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 29 23:02:10 2019 Received: (at submit) by debbugs.gnu.org; 30 Mar 2019 03:02:10 +0000 Received: from localhost ([127.0.0.1]:36129 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hA4G2-0006pE-Gu for submit@debbugs.gnu.org; Fri, 29 Mar 2019 23:02:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60275) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hA4G0-0006kO-LB for submit@debbugs.gnu.org; Fri, 29 Mar 2019 23:02:08 -0400 Received: from lists.gnu.org ([209.51.188.17]:50158) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hA4Ft-0005PT-CV for submit@debbugs.gnu.org; Fri, 29 Mar 2019 23:02:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hA4Fk-0001Ug-On for bug-grep@gnu.org; Fri, 29 Mar 2019 23:01:56 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_50,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hA4Fj-0005M1-R6 for bug-grep@gnu.org; Fri, 29 Mar 2019 23:01:52 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:40339) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hA4Fj-0005LP-Kq for bug-grep@gnu.org; Fri, 29 Mar 2019 23:01:51 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 1AD6C21EF8 for ; Fri, 29 Mar 2019 23:01:50 -0400 (EDT) Received: from imap28 ([10.202.2.78]) by compute1.internal (MEProxy); Fri, 29 Mar 2019 23:01:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=IKfZ3e WQGLvMtuKUE5mBDBEmQPkihoW3qBtfblLaDmI=; b=zoj3lS2R6G3j1F/n7kYPDJ Lt6zrn6r7hvlwB5jZNBHU7KWD9tVZUNAAz0Hb4rHXi7U87GoZHslsIq3O2QscxXp NcIXFMqKk+xTTT4VeJecgg7tdNjpjXpuTLx32fcFxXhkWcqkD5Gpmxfw+wMG0YQ2 s3xf6QPG1iUvFhWTmquww1sQeuyKTQywkhJdv0C1YC88ZXc9hDj0QDn4zgYorK8X VkA8noCXmRBhZrhgcGO6Fr5xOztkTtpDWfbNLhr9GQRfS12fh4j+p+890ER6vTAB K42gJfmQux04meeWtC2kMIXiUTc1BJYazJVAtwgmeW4GyYyCWOP9nlEAmyj6mQxw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrkeekgdehfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesrgdtre erreerjeenucfhrhhomhepfdfrrghulhculfgrtghkshhonhdfuceophhjsehushgrrdhn vghtqeenucfrrghrrghmpehmrghilhhfrhhomhepphhjsehushgrrdhnvghtnecuvehluh hsthgvrhfuihiivgeptd X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 713354E636; Fri, 29 Mar 2019 23:01:49 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.6-329-gf4aae99-fmstable-20190329v1 Mime-Version: 1.0 X-Me-Personality: 78241 Message-Id: <0f7c5c36-a0ed-4437-908b-09d0c69d78d6@www.fastmail.com> In-Reply-To: References: Date: Fri, 29 Mar 2019 23:01:48 -0400 From: "Paul Jackson" To: bug-grep@gnu.org Subject: =?UTF-8?Q?Re:_bug#35043:_Is_there_a_way_to_show_file_name_once_just_befo?= =?UTF-8?Q?re_all_the=09matches_in_the_file=3F?= Content-Type: multipart/alternative; boundary=fe1641a6dbed4bfbbb343f0f8ed60b71 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.28 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) --fe1641a6dbed4bfbbb343f0f8ed60b71 Content-Type: text/plain 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 --fe1641a6dbed4bfbbb343f0f8ed60b71 Content-Type: text/html Content-Transfer-Encoding: quoted-printable

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

grep IP /etc/protocols /etc/services |
    awk -F: '
<= div style=3D"font-family:Arial;">    &nb= sp;   $1 !=3D fname { print $1 ":"; fname =3D $1; }
&n= bsp;       { sub("^[^:]*:", ""); print; }<= /span>
    '

--&= nbsp;
    = ;            Paul= Jackson
   &n= bsp;            p= j@usa.net
--fe1641a6dbed4bfbbb343f0f8ed60b71-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 02 04:27:30 2020 Received: (at control) by debbugs.gnu.org; 2 Jan 2020 09:27:31 +0000 Received: from localhost ([127.0.0.1]:38160 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1imwlO-0007sB-LR for submit@debbugs.gnu.org; Thu, 02 Jan 2020 04:27:30 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:47270) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1imwlN-0007rx-3C for control@debbugs.gnu.org; Thu, 02 Jan 2020 04:27:29 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id BE0D7160017 for ; Thu, 2 Jan 2020 01:27:23 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id poJIlexiElxE for ; Thu, 2 Jan 2020 01:27:23 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2C193160054 for ; Thu, 2 Jan 2020 01:27:23 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 0t66EvypwsIY for ; Thu, 2 Jan 2020 01:27:23 -0800 (PST) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 0C749160017 for ; Thu, 2 Jan 2020 01:27:23 -0800 (PST) To: control@debbugs.gnu.org From: Paul Eggert Subject: 35043 is wishlist Organization: UCLA Computer Science Department Message-ID: <5680a560-335b-c1c1-2440-b26b7b94fc22@cs.ucla.edu> Date: Thu, 2 Jan 2020 01:27:22 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) severity 35043 wishlist