Comment by teddyh

11 years ago

Let me fix this with a one-line shell function:

  eg(){ man "$@" 2>/dev/null|sed -ne '/^EXAMPLE/{:a;p;n;/^[^ ]/q;ba}'|${MANPAGER:-pager -s};}

Now there’s an “eg” command to display just the EXAMPLES (or EXAMPLE) section of a Unix manual page.

For example:

  $ eg cat
  EXAMPLES
       cat f - g
              Output f's contents, then standard input, then g's contents.
  
       cat    Copy standard input to standard output.

If the command gives no output, the manual has no EXAMPLES section. Consider writing some examples and submitting a patch to the manual.

There, I fixed it. Now nobody needs this program (or should I say “brogram”) anymore. (Thanks to pbhjpbhj for the name: https://news.ycombinator.com/item?id=7122063)