From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.bugs Subject: bug#44983: Truncate long lines of grep output Date: Thu, 10 Dec 2020 00:43:23 +0300 Message-ID: References: <83pn3reyjs.fsf@gnu.org> <87y2ie7for.fsf@mail.linkov.net> <87h7p0f611.fsf@mail.linkov.net> <87a6uqafmk.fsf@mail.linkov.net> <87zh2q61n6.fsf@mail.linkov.net> <3620abd0-ce79-cc9d-3fb2-255e91f13da1@yandex.ru> <87mtyo3x1z.fsf@mail.linkov.net> <857088a6-fe90-d989-9115-2c159b2a02e6@yandex.ru> <87lfe6x1uf.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12033"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0 (3d08634) (2020-11-07) Cc: 44983@debbugs.gnu.org, Dmitry Gutov To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 09 22:47:46 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kn7JJ-000329-ON for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 09 Dec 2020 22:47:45 +0100 Original-Received: from localhost ([::1]:34818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kn7JI-0001Rz-N1 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 09 Dec 2020 16:47:44 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn7Ib-0001Qv-UW for bug-gnu-emacs@gnu.org; Wed, 09 Dec 2020 16:47:01 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53078) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kn7Ib-0004B2-Mk for bug-gnu-emacs@gnu.org; Wed, 09 Dec 2020 16:47:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kn7Ib-0003g6-Lr for bug-gnu-emacs@gnu.org; Wed, 09 Dec 2020 16:47:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jean Louis Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 09 Dec 2020 21:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44983 X-GNU-PR-Package: emacs Original-Received: via spool by 44983-submit@debbugs.gnu.org id=B44983.160755038814094 (code B ref 44983); Wed, 09 Dec 2020 21:47:01 +0000 Original-Received: (at 44983) by debbugs.gnu.org; 9 Dec 2020 21:46:28 +0000 Original-Received: from localhost ([127.0.0.1]:36391 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kn7I3-0003fG-UX for submit@debbugs.gnu.org; Wed, 09 Dec 2020 16:46:28 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:56469) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kn7I2-0003f0-4Z for 44983@debbugs.gnu.org; Wed, 09 Dec 2020 16:46:26 -0500 Original-Received: from localhost ([::ffff:41.202.241.31]) (AUTH: PLAIN securesender, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000001E43F.000000005FD145AA.00006024; Wed, 09 Dec 2020 14:46:18 -0700 Content-Disposition: inline In-Reply-To: <87lfe6x1uf.fsf@mail.linkov.net> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:195603 Archived-At: Also see this: https://www.topbug.net/blog/2016/08/18/truncate-long-matching-lines-of-grep= -a-solution-that-preserves-color/ ,---- | For the example above, the following command should print only 20 | characters before and after the searching keyword (This requires GNU | grep. If you are on Mac OS X and using the BSD grep, please consider | following this article to install GNU grep): |=20 | grep -oE '.{0,20}jQuery.{0,20}' bootstrap.min.js `---- where I get this: grep -o --color -nH --null -E ".{0,20}setting.{0,20}" tmp-2020-11-26-01:3* tmp-2020-11-26-01:32:17986egO=003: supported, but its setting does not have= prior Grep finished with 1 match found at Thu Dec 10 00:42:21 =66rom this line long made-up line: =E2=80=98--color[=3DWHEN]=E2=80=99 =E2=80=98--colour[=3DWHEN]=E2=80=99 Surr= ound the matched (non-empty) strings, matching lines, context lines, file n= ames, line numbers, byte offsets, and separators (for fields and groups of = context lines) with escape sequences to display them in color on the termin= al. The colors are defined by the environment variable =E2=80=98GREP_COLOR= S=E2=80=99 and default to =E2=80=98ms=3D01;31:mc=3D01;31:sl=3D:cx=3D:fn=3D3= 5:ln=3D32:bn=3D32:se=3D36=E2=80=99 for bold red matched text, magenta file = names, green line numbers, green byte offsets, cyan separators, and default= terminal colors otherwise. The deprecated environment variable =E2=80=98GR= EP_COLOR=E2=80=99 is still supported, but its setting does not have priorit= y; it defaults to =E2=80=9801;31=E2=80=99 (bold red) which only covers the = color for matched text. WHEN is =E2=80=98never=E2=80=99, =E2=80=98always=E2= =80=99, or =E2=80=98auto=E2=80=99. =E2=80=98-L=E2=80=99 =E2=80=98--files-wi= thout-match=E2=80=99 Suppress normal output; instead print the name of each= input file from which no output would normally have been printed. The sca= nning of each file stops on the first match. =E2=80=98-l=E2=80=99 =E2=80=98= --files-with-matches=E2=80=99 Suppress normal output; instead print the nam= e of each input file from which output would normally have been printed. T= he scanning of each file stops on the first match. (=E2=80=98-l=E2=80=99 i= s specified by POSIX.) and that solves the problem of truncating long lines.