Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gwpl/d8d7cf7f29c7faacab82439482bcd4ae to your computer and use it in GitHub Desktop.
Save gwpl/d8d7cf7f29c7faacab82439482bcd4ae to your computer and use it in GitHub Desktop.
Grep e.g. `man` page for specific paragraph - `gawk` AND comparison of "AIs" answers

example of use of best Answer:

$ man journalctl 2>/dev/null | gawk -v RS='' '/-S.*--since/'
       -S, --since=, -U, --until=
           Start showing entries on or newer than the specified date, or on or
           older than the specified date, respectively. Date specifications
           should be of the format "2012-10-30 18:17:16". If the time part is
           omitted, "00:00:00" is assumed. If only the seconds component is
           omitted, ":00" is assumed. If the date component is omitted, the
           current day is assumed. Alternatively the strings "yesterday",
           "today", "tomorrow" are understood, which refer to 00:00:00 of the
           day before the current day, the current day, or the day after the
           current day, respectively.  "now" refers to the current time.
           Finally, relative times may be specified, prefixed with "-" or "+",
           referring to times before or after the current time, respectively.
           For complete time and date specification, see systemd.time(7). Note
           that --output=short-full prints timestamps that follow precisely
           this format.

to prompt:

I would like to grep description of one flag from man page. Each flag description in man output is seaprated by empty line. So I would ike to man manpage | .... 'foo'  to display full description of each flag that any part of their description matches foo. I wondred if to achieve this with riggrep multiline or normal grep or other way on ArchLinux or Debian systems?

answer from Grok3 beta + reasoning that WON!

All answers as of 2025-03-09 from:

There

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment