Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Example: ssh_config

I've set a filetype in vim for this. I want the help program to be


Of course this does not work, if I am on a word, say


I get an error, since there is no man pager for ServerAliveCountMax, it's inside ssh_config's manpage.

Is there any way to, from the command line, jump to a string or run some type of command inside man? Much like info actually:

info screen Miscellaneous

will take me to the Miscellaneous section of screens info page.

Is this possible with man? Even running a search would serve...

EDIT: I'm using OSX 10.6.5. with the default man ( /usr/bin/man)

EDIT: I speak a bit of dialect ;) , so I was led to the correct answer:

man -P 'less -p PATTERN' ssh_config  

Is the invocation on OSX/*BSD it would seem.

share|improve this question
up vote 6 down vote accepted

From the command line for GNU man:

man --pager='less -p ^ENVIRONMENT' man

or for BSD man:

man -P 'less -p ^ENVIRONMENT' man

will jump to the "ENVIRONMENT" heading of the man page for man.

Here is a handy function:

mans () {    # Bash
    local pages string
    if [[ -n $2 ]]
    # GNU man
    man ${2:+--pager="less -p \"$string\" -G"} ${pages[@]}
    # BSD man
    # man ${2:+-P "less -p \"$string\" -G"} ${pages[@]}


Use normally:

mans bash

Go to the "DESCRIPTION" heading:

mans ^DESCRIPTION bash

Go to the "DESCRIPTION" heading of each man page in succession (press q and Enter to go to the next one):

mans ^DESCRIPTION bash ksh zsh

Go to the "Parameter Expansion" sub-heading (you can search for any string using regular expressions):

mans '^ *Parameter Expansion' bash

Search for the most recent regex you've used in Less:

mans '' bash

The match that you searched for won't be highlighted. If you'd prefer it to be, just remove the -G from the options to less.

This function makes no attempt to handle the other arguments and options that man supports.

share|improve this answer
promising, I edited my question, I see you ran that using either macports or linux, I have a -P option in the crappy BSD style option list... trying that. – chiggsy Nov 29 '10 at 2:32
Thanks, I got it, but thanks again! BAH, I can't upvote your new answer again :( – chiggsy Nov 29 '10 at 2:40
@Chiggsy: I take it the -P worked. If so, I'll add it to my answer. – Dennis Williamson Nov 29 '10 at 2:41
For the record, I upvoted your original answer. It was completely correct. Your edit , i was unable to upvote. I wanted to though... – chiggsy Nov 29 '10 at 2:45
@Chiggsy: Should I add the -P BSD-style to my answer for future reference? – Dennis Williamson Nov 29 '10 at 2:47

In man you can type / followed by a pattern to match e.g. to find the DEFAULT KEY BINDINGS section of the screen man page you would type

share|improve this answer
Yes. This is true, but you have to be in man to do it. I want to get from the shell to that in one step. – chiggsy Nov 29 '10 at 2:22

/ in less will do a forward search, and ? will do a reverse search. Press h to see a full list.

share|improve this answer
See my comment above, and actually, my question. – chiggsy Nov 29 '10 at 2:23

Your Answer


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.