Is there way to see `man` document only for specified option of a command

If you use less as pager for man you can try

LESS="+/^\s+-b" man wget

where

  1. + symbol to execute next operation after less has opened
  2. / command to start search
  3. ^\s+-b regexp to match -b from start of line

So if you like you can arrange the apropriate function for shell

function rman {
#USAGE: rman programm.name option.to.search (with "-" symbol)
LESS="+/^\s+$2" man "$1"
}

and add it into ~/.bashrc for example.


When you run man command you can press / and then enter the plain text to search for. For example, type /-b and it'll jump to the first instance of -b in the text.


I wrote a small script to do this called he, e.g. he wget -b.

The basic strategy is: search for the option (e.g. -b) as the first word on a line, then print until the next header, or next line with matching indentation.

If you can't use that, you can get something similar using basic sed, e.g.

man wget | sed -ne '/^  *-b/,/^$/p'

Tags:

Options

Man