How to jump to a particular flag in a Unix manpage?
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.
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.
Also you can open the man page on specific position from command line with
man -P 'less -p " -o"' mount