How do I go directly to a particular (short) option on a manpage
سؤال
Often I will open up the manpage for a command already knowing the option I am searching for and read its description. Sometimes simply searching for the option works immediately, sometimes the option is referenced elsewhere, sometimes the option just appears as a substring in the preceding text.
As a concrete example, on my computer, right now, this is the sequence of commands to get to the -l
option of ls
:
man ls
/-l
nnnnnnn
In this particular case there is only one group of options and they are alphabetically sorted, so I could just scroll down and find the option, or do as above. In other cases not so much. Regardless, I would like to go directly to the line.
المحلول
If your pager is less
, which it often is, it supports regular expression search. For your example this works:
man ls
/^ *-l\b
Which anchors the match to lines starting with arbitrary whitespace followed by -l
and a word-boundary \b
.
نصائح أخرى
In this particular case I can do a search:
/ -l
Or even just
/ -l
This doesn't always work immediately, though, so I'm hoping there's a better answer still.