Super User is a question and answer site for computer enthusiasts and power users. 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

When reading a Unix manpage in the terminal, how can I jump easily to the description of a particular flag?

For instance, I need to know the meaning of the -o flag for mount. I run man mount and want to jump to the place where -o is described. Currently, I search /-o however that option is mentioned in several places before the section that actually describes it, so I must jump around quite a bit.


share|improve this question
up vote 19 down vote accepted

What I do is put a few blank spaces in front of the flag like so:

"/     -o"

That's not 100% reliable but you jump through a much less hoops. If you want even better success rate, try "/^ +-o". That would find lines starting with blanks and followed by -o. I wouldn't like to type that weird string often though.

share|improve this answer
Thank you. That does get the job done! – dotancohen Jun 26 '12 at 10:23

I have defined this function in my .bashrc

function manswitch () { man $1 | less -p "^ +$2" }

which you can use as follows

manswitch grep -r

I got it from this commandlinefu

Note: the argument to the -p switch of less is a regexp telling less to look for a line starting with (^) one or more spaces (" +") followed by the switch (second arg. so $2), so it has the advantage of working with different formatting.

share|improve this answer

Also you can open the man page on specific position from command line with

man -P 'less -p "     -o"' mount
share|improve this answer
Upvoted for being possible, but that is quite a bit more to type than to search from within man. Thanks, though! – dotancohen Jun 26 '12 at 12:35
That's pretty useful to send someone to the exact place in the man page :) – rush Jun 26 '12 at 12:38
Yes, I was just thinking that if I had to open a man page in a script for some reason it would be useful as well. Thank you! – dotancohen Jun 26 '12 at 12:38

The other solutions are quite good, but also remember that man pages are just data and you can easily do almost anything with them in Linux.

man some-command > file.txt

converts the page into a plain text file you can then manipulate. I keep a copy of the bash manual as text in my bin directory so I can just load it into my text editor to search for things and copy and paste while I'm editing scripts.

Or you can pipe it into filters such as

man some-command | grep -A lines-after "some pattern"

Although it wouldn't work for you in a terminal, I (with the help of a friend) even wrote a script that grabs a man page and displays it in a web browser so I can use its navigation/search features which are way better than less. It's a bit kde dependent, but easy to modify.

share|improve this answer
You might want to try man:// in Konqueror. KDE has a manpage KIOSLAVE! – dotancohen Jul 3 '12 at 10:09
@dotancohen - Cool. Didn't know about that. – Joe Jul 4 '12 at 16:48
@dotancohen -I just tried it in dolphin and it also works, but displays the man pages as directories and files and launches your default browser when you click on a file. I don't iunderstand the part about KIOSLAVE. I tried man://kioslave and it was the same as man://. – Joe Jul 4 '12 at 16:56
@dotancohen - Never mind - I looked up kioslaves on wikipedia. – Joe Jul 4 '12 at 17:06
Yeah, KDE has just about everything. Enjoy! – dotancohen Jul 4 '12 at 18:11

@piccobello's answer is great, but it was eating the colors in my man pages. Instead of piping to less (since man already uses less by default usually), I simply pass the modified less command to man:

function manswitch() { man -P "less -p \"^ +$2\"" $1 }

This retains the functionality @piccobello had in his function, but retains colors.

share|improve this answer

I wrote a tool that does just this, called flagman. Still in development but already usable. For example:

$ ./flagman mount -o
       -o, --options opts
              Use the specified mount options.  The opts argument is a comma-separated list.  For example:

                     mount LABEL=mydisk -o noatime,nodev,nosuid

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .