Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
man find

opens up the man page for find in my pager.

Is there something like

example find

that would print

find /usr/lib -name "stdint.h"
share|improve this question
I'm not entirely sure if I understand you correctly: Are you just looking for examples for common commands? Note that many manpages have a section dedicated to examples. – slhck Jul 30 '12 at 21:08
Yes, that's what I'm looking for. Is there a quick way to just print the examples? – William Bettridge-Radford Jul 30 '12 at 21:09
up vote 4 down vote accepted

Is there a quick way to just print the examples?


 man find | perl -ne 'print if /^EXAMPLE/.../^[A-Z]/'

Similar solutions must exist using awk etc

 man find | awk '/^EXAMPLES/,/^EXIT/ { print }'
share|improve this answer
Notes: On Mac OS X, the specified perl invocation fails because the output of man actually contains E\bEX\bXA\bAM\bMP\bPL\bLE\bE', where \b` is backspace; if you do can pass those backspace characters to perl, it works. However, perl doesn't seem to interpret the actual sequence \b like that, so the only way I've found is with bash's $'' quoting: man find | perl -ne $'print if /^E\bEX\bXA\bAM\bMP\bPL\bLE\bE/.../^[A-Z]/'. – echristopherson Aug 5 '12 at 22:57
Continued: I can't get the awk example to work; EXIT doesn't occur right after the EXAMPLES section in OS X, and awk on OS X doesn't work with [A-Z], but at least it does recognize \b. – echristopherson Aug 5 '12 at 22:57
You can probably prefix the command with TERM=something to prevent man inserting special formatting characters. Perhaps man on OSX has some options fo this? – RedGrittyBrick Aug 6 '12 at 8:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .