unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Juri Linkov <juri@linkov.net>
Cc: 44983@debbugs.gnu.org, Dmitry Gutov <dgutov@yandex.ru>
Subject: bug#44983: Truncate long lines of grep output
Date: Thu, 10 Dec 2020 00:43:23 +0300	[thread overview]
Message-ID: <X9FE+14vRj+xMTiJ@protected.rcdrun.com> (raw)
In-Reply-To: <87lfe6x1uf.fsf@mail.linkov.net>

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):
| 
| 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\03: supported, but its setting does not have prior

Grep finished with 1 match found at Thu Dec 10 00:42:21

from this line long made-up line:

‘--color[=WHEN]’ ‘--colour[=WHEN]’ Surround the matched (non-empty) strings, matching lines, context lines, file names, line numbers, byte offsets, and separators (for fields and groups of context lines) with escape sequences to display them in color on the terminal.  The colors are defined by the environment variable ‘GREP_COLORS’ and default to ‘ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36’ 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 ‘GREP_COLOR’ is still supported, but its setting does not have priority; it defaults to ‘01;31’ (bold red) which only covers the color for matched text. WHEN is ‘never’, ‘always’, or ‘auto’. ‘-L’ ‘--files-without-match’ Suppress normal output; instead print the name of each input file from which no output would normally have been printed.  The scanning of each file stops on the first match. ‘-l’ ‘--files-with-matches’ Suppress normal output; instead print the name of each input file from which output would normally have been printed.  The scanning of each file stops on the first match.  (‘-l’ is specified by POSIX.)

and that solves the problem of truncating long lines.






  parent reply	other threads:[~2020-12-09 21:43 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-01  8:45 bug#44983: Truncate long lines of grep output Juri Linkov
2020-12-01 15:02 ` Dmitry Gutov
2020-12-01 16:09   ` Eli Zaretskii
2020-12-01 16:46     ` Andreas Schwab
2020-12-01 18:26       ` Eli Zaretskii
2020-12-01 20:35     ` Juri Linkov
2020-12-02  3:21       ` Eli Zaretskii
2020-12-02  9:35         ` Juri Linkov
2020-12-02 10:28           ` Eli Zaretskii
2020-12-02 20:53             ` Juri Linkov
2020-12-03 14:47               ` Eli Zaretskii
2020-12-03 16:30                 ` Rudolf Schlatte
2020-12-03 21:17                 ` Juri Linkov
2020-12-05 19:47                   ` Juri Linkov
2020-12-06 20:39                     ` Juri Linkov
2020-12-06 21:37                       ` Dmitry Gutov
2020-12-06 21:54                         ` Juri Linkov
2020-12-07  2:41                           ` Dmitry Gutov
2020-12-08 19:41                             ` Juri Linkov
2020-12-09  3:00                               ` Dmitry Gutov
2020-12-09 19:17                                 ` Juri Linkov
2020-12-09 20:06                                   ` Dmitry Gutov
2020-12-10  8:18                                     ` Juri Linkov
2020-12-10 20:48                                       ` Dmitry Gutov
2020-12-09 21:43                                   ` Jean Louis [this message]
2020-12-10  8:06                                     ` Juri Linkov
2020-12-10 10:08                                       ` Jean Louis
2020-12-12 20:42                                         ` Juri Linkov
2020-12-13 10:57                                           ` Jean Louis
2020-12-13 15:11                                           ` Eli Zaretskii
2020-12-13 15:37                                             ` Jean Louis
2020-12-13 20:17                                             ` Juri Linkov
2020-12-14 16:15                                               ` Eli Zaretskii
2020-12-14 20:09                                                 ` Dmitry Gutov
2020-12-24 20:33                                   ` Juri Linkov
2020-12-24 23:38                                     ` Dmitry Gutov
2020-12-08  5:35                         ` Richard Stallman
2020-12-08 19:15                           ` Dmitry Gutov
2022-04-29 11:39           ` Lars Ingebrigtsen
2022-04-29 12:22             ` Eli Zaretskii
2022-04-29 12:41               ` Lars Ingebrigtsen
2022-04-29 13:08                 ` Eli Zaretskii
2022-04-30  9:24                   ` Lars Ingebrigtsen
2022-04-30  9:36                     ` Lars Ingebrigtsen
2022-04-30 10:15                       ` Eli Zaretskii
2022-04-30 11:04                         ` Lars Ingebrigtsen
2022-04-29 16:02             ` Dmitry Gutov
2022-04-30  9:40               ` Lars Ingebrigtsen
2022-04-30  9:56                 ` Lars Ingebrigtsen
2022-04-30 10:09                   ` Eli Zaretskii
2022-04-30 10:59                     ` Lars Ingebrigtsen
2022-04-30 11:02                     ` Lars Ingebrigtsen
2022-04-30 11:12                       ` Eli Zaretskii
2022-04-29 17:15             ` Juri Linkov
2022-04-30  0:27               ` Dmitry Gutov
2022-05-01 17:14                 ` Juri Linkov
2020-12-01 20:34   ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=X9FE+14vRj+xMTiJ@protected.rcdrun.com \
    --to=bugs@gnu.support \
    --cc=44983@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).