How to jump to a particular flag in a Unix manpage?
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Flying Over Ancient Lands
--
Chapters
00:00 How To Jump To A Particular Flag In A Unix Manpage?
00:30 Accepted Answer Score 33
00:54 Answer 2 Score 5
01:05 Answer 3 Score 16
01:34 Answer 4 Score 5
01:58 Thank you
--
Full question
https://superuser.com/questions/441654/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #unix #man
#avk47
ACCEPTED ANSWER
Score 33
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.
ANSWER 2
Score 16
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.
ANSWER 3
Score 5
Also you can open the man page on specific position from command line with
man -P 'less -p " -o"' mount
ANSWER 4
Score 5
@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.