grep and manpages

Can I use grep and textproc/bsdgrep to locate underlined words including headers within manpages? So far it can get search for any header not underlined within that manpage.
The headers can be included in the search with A (after) and B (before) options. The -i (case) argument didn't work either for locating underlined headers.

man rc.conf | grep -A2 -B2 kld_list.
 
Instead of using grep to filter the content in the man page you can open the man page then use internal search function of the "more or less pager". For example if you are searching for "kld"
open the man page man rc.conf
type /kld inside the man page hit enter this will search for the first match of "kld" ( / =
to search for next match press "n"

/pattern * Search forward for (N-th) matching line.
?pattern * Search backward for (N-th) matching line.
n * Repeat previous search (for N-th occurrence).
N * Repeat previous search in reverse direction.


Edit: if you are using "less" then the search pattern is highlighted in the entire document. It depend of your default PAGER env.

Why would someone use "more" if they can use "less"?
 
Both solutions are good.

Strip the escape sequences first:
man rc.conf | col -b | grep -A2 -B2 kld_list

What are you trying to do?
Trying to search for the underlined item of any manpage, and what comes after it.
man rc.conf | col -b | grep -A3 kld. The -B option was to show of the inconvenient way, that didn't always work, I used it to turned up a category.
 
Back
Top