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.

Is there a option to search within manpages?

share|improve this question
    
Do you mean search within all the manpages to find which one has certain content, or search within one given manpage for a certain phrase? –  frabjous Jan 9 '11 at 16:32
    
@frabjous i meant within one manpage, is there also a option to search all? –  NES Jan 9 '11 at 16:49
2  
I added that too. By the way, you can also type man man to read all of the technical details about man-pages. –  Stefano Palazzo Jan 9 '11 at 16:59
add comment

1 Answer 1

up vote 34 down vote accepted

Just hit /, and type your search pattern.

  • Patterns can be regular expressions, for example, you could search for the word "option" by typing

    /[Oo]ption
    

    Or find all of the long arguments with

    /(--)[a-Z]
    

    To cancel the search, hit Ctrl+C.

    Some useful quantification operators are:

    ?    for zero or one of the preceding expression
    *    for zero or more of the preceding expression
    +    for one or more of the preceding expression
    

    And expressions can be "grouped" with parentheses, as in (--)+ (for two or more dashes).

    [a-Z] is a sequence (others include [0-9], [a-z] and so on), they can be combined, as in [a-Z0-9]. You can also invert expressions with the ^ operator, e.g. (--)[^a-Z]+ for all long arguments that start with anything other than a letter.

    Another useful operation is Union (|), as in color|colour, which finds every occurrence of either color or colour (this is sometimes called boolean OR).

  • To jump through the results, press N (forwards) and Shift+N (backwards).

  • There is also a way to search across all manpages:

    man -K "Hello World"
    

    The man program will open the first match, and after you close it with q, offer you to

    • view the next one (Return)
    • skip the current one (Ctrl+D)
    • or exit (Ctrl+C).
share|improve this answer
1  
this depends on your pager alternative: update-alternatives --display pager. This is correct for less –  shellholic Jan 9 '11 at 16:35
    
is there also an option to browse through the results with a key? i.e. as in firefox you would press F3 and the cursor jumps from one result to the next? –  NES Jan 9 '11 at 16:37
    
Sorry, I forgot to mention it. Added it to the answer. –  Stefano Palazzo Jan 9 '11 at 16:38
1  
great, thanks, a lot. –  NES Jan 9 '11 at 16:48
1  
Another useful tip for less, instead of using [oO][pP]... for each character, use -i to toggle case sensibility. –  Lekensteyn Jan 22 '11 at 14:55
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.