I would like to search through subsection FILES in all man pages.

I have tried man -K FILES:resolv.conf and man -K -S FILES resolv.conf in no way

How can I do that?


The -S option selects a section of the manual, the manual being the whole collection of man pages. The manual section can be 1 (Executables), 2 (System calls) etc. Not the section of a single man page as such. So for example

man -K -S 3 resolv.conf

will return the man page for res_init(3), a C library call that belongs into the section 3, Library calls, but not the man page for dig(1), which belongs to section 1 (executables).

Since this is a brute text search anyways, I would probably make an ad hoc search script using zcat and sed, or maybe a simple perl script.

EDIT: here is an example script, created as bash function.

function mfind { find /usr/share/man/ -iname '*.gz' -exec zcat {} \; | perl -ne '/.SH NAME/ and $n=<STDIN>;/.SH '$2'/ and $c=1;$c and /'$1'/ and $n and print "$n" and $n=""' ; }


mfind expression mansection

for example

mfind utmp FILES

Bugs: does not consider /etc/manpath.config, uses /usr/share/man instead. No further options available.

  • According to this link it is possible on Solaris. Is that not applicable to ubuntu? – user52151 Sep 19 '12 at 13:27
  • No, I'm afraid not (and not to GNU man in general). – January Sep 19 '12 at 14:19
  • 1
    (There is no such thing as GNU man. Neither the now-mostly-obsolete man package nor the man-db package which Ubuntu uses have ever been GNU projects.) – Colin Watson Oct 22 '12 at 23:28
  • Yes, my bad; sorry. – January Oct 23 '12 at 5:16
  • Nice, but there is a simpler solution. See my answer. – Elder Geek Jun 2 '14 at 15:29

man -K FILES

Tested functional under ubuntu 12.04

Simple and effective.




In your specific case you are looking for:

man -K FILES "resolv.conf"



Please file a bug for this, preferably against the man-db package in Debian, but you can file it in Ubuntu instead if you like. I don't promise to get around to implementing it any time soon (I'm man-db upstream), but it's an interesting feature in Solaris that I was unaware of and it would have occasional uses.

  • I don't think it's so much a bug as an imperfectly assembled command.. See my answer. – Elder Geek Jun 2 '14 at 15:30

I wouldn't say no options. I've been trying to put together a consolidated file in .txt or .pdf format of the complete man resource. The option I opted for was

man -a /bin/* > manList.txt

(still experimenting with it for improvement, obviously). I'm far from an expert, so it has its kinks(some groups of text have sections of characters not displayable, I assume something involving the encoding around the page-breaks, not sure.) However, in reference to your question, it seems feasible that

man -a 5 /bin/* /sbin/* > {your_output_file}

would be at least a workable option until you can find something better. I tested it, same encoding issue, but the data is there for access, just needs some TLC. Then you could search at your leisure with a txt editor. Hope this helps.

  • There's an easier way. See my answer. – Elder Geek Jun 2 '14 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.