I'd like to search for a certain string in all system man pages, but I only want to get a list of the man pages where this text appears. The first 2 pages of results Google returned do not provide the answer I'm after, if at all such an answer exists.
Let me explain:
I'd like to see all man pages where the word hairpin
appears. I proceed to type man -K hairpin
, and the contents that appear are akin to me having typed man nmcli
. When I exit this man page via q, the following then appears on my screen:
--Man-- next: bridge(8) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]
From here, I can continuously type Ctrl+D and eventually return to the command prompt with the following displayed above the prompt:
--Man-- next: bridge(8) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]
--Man-- next: lldptool-evb22(8) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]
--Man-- next: systemd.network(5) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]
--Man-- next: nm-settings(5) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]
--Man-- next: nm-settings-ifcfg-rh(5) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]
--Man-- next: systemd.directives(7) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]
What I'm asking is, is it possible to get a listing of the man pages
where hairpin
appears such as below?:
man -<some-option> -K hairpin
nmcli(1)
bridge(8)
lldptool-evb22(8)
systemd.network(5)
nm-settings(5)
nm-settings-ifcfg-rh(5)
systemd.directives(7)
Edit:
Searching Google using a sentence doesn't always return the results where the specific query is addressed. This is obviously the case for this question, as pointed out by several that it is indeed a duplicate.
However, it would be best not to delete it as it shows the specific output returned on Ubuntu systems. A user on Ubuntu may benefit from this question.
Edit 2:
Searching for skip (Ctrl-D)
now has this question appearing in the first page of Google results where previously nothing was returned!
PAGER="head -1" man -K hairpin </dev/null
good enough for you? – Celada Mar 27 '16 at 12:39man
to allow for this. – AnthonyK Mar 27 '16 at 12:48PAGER='awk "NR==1{print $1}"' man -K hairpin </dev/null
or evenPAGER='perl -lane "print lc($F[0]) if $.==1"' man -K hairpin </dev/null
. Celada, why not whip that into an answer? – terdon Mar 27 '16 at 12:59