Operating System - HP-UX
1833730 Members
2072 Online
110063 Solutions
New Discussion

just the option descriptors without all the man page garbage

 
rightbrain
Advisor

just the option descriptors without all the man page garbage

How can I show a very brief (less than one line) descriptor of a particular command and very brief (one line or less) descriptors of the various options. Each man page for a particular command is several pages and I really could do without it. Usage data would be good to have too but I don't need a book where a line will do. Any thoughts on this?

I wrote this question on experts exchange and they came up with a complicated command to parse the information I needed that I could alias for each system if need be.

If there is a better approach, I would love to know about it. Any help would be greatly appreciated.
give my right brain some warning will ya?
6 REPLIES 6
Patrick Wallek
Honored Contributor

Re: just the option descriptors without all the man page garbage

As far as I know, there is no easy way to do this.

If you look at 'man man' there are very few options to the man command itself.
James R. Ferguson
Acclaimed Contributor

Re: just the option descriptors without all the man page garbage

Hi:

Well, this gives a summary (albeit without each option's description):

# man command|col -b|awk '/NAME/,/DESCRIPTION/'

...replace 'command' with whatever you want summarized.

Regards!

...JRF...
TTr
Honored Contributor

Re: just the option descriptors without all the man page garbage

http://hpux.cs.utah.edu/hppd/hpux/Misc/woman-3.0/

I have not used it but it claims to come with "apropos" and "whatis" which is what you need.
Dennis Handly
Acclaimed Contributor

Re: just the option descriptors without all the man page garbage

>JRF: man command|col -b|awk '/NAME/,/DESCRIPTION/'

And pipe it to rmnl(1) to remove blank lines.
Hein van den Heuvel
Honored Contributor

Re: just the option descriptors without all the man page garbage

>> I wrote this question on experts exchange and they came up with a complicated command to parse the information I needed that I could alias for each system if need be.

Too bad you did not share the details.

Parsing man output is not hard, but not trivial either due to its 'stuttering' trying to 'overstrike' the key words.

For example, the line with ' SYNOPSIS looks like:
$ man awk| awk 'NR==12' | od -c
... S \b S \b S \b S Y \b Y \b Y \b Y N

So any matching looks ugly.

Here is an AWK solution, which you probably should put in a script or alias of ease of use:

$ COMMAND=awk
$ man $COMMAND 2>/dev/null | awk 'x {x=0;print $0} /S\bSY/ {x=1} / -\b-/'

awk [-Ffs] [-v var=value] [program | -f progfile ...] [file ...]
-F fs Specify regular expression used to separate
-f progfile Specify an awk program file. Up to 100 program
-v var=value Cause var=value assignment to occur before the

Using perl:

$ man $COMMAND 2>/dev/null | perl -ne '$p and print and $p=0; $p++ if /S.SY/; print if /^\s+-.-/'

or perl hiding the IFfy parts...

$ man tail 2>/dev/null | perl -ne '$p and print and $p=0; $p=/S.SY/; /^\s+-.-/ and print'

or perl picking up the command as argument for easy scripts / command line edit:

perl -e '$c=shift; foreach (qx(man $c 2>/dev/null)){if ($p){$p=0;print} $p++ if /S.SY/;print if /^\s+-.-/}'

so many ways...

:-)

hth,
Hein.
Dennis Handly
Acclaimed Contributor

Re: just the option descriptors without all the man page garbage

>Hein: but not trivial either due to its 'stuttering' trying to 'overstrike' the key words.

As shown in JRF's fragment, "col -b" removes that stuff.