Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

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=""' ; }

Usage:

mfind expression mansection

for example

mfind utmp FILES

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

share|improve this answer
    
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
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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