For example instead of whole manual of apt-get
I want jump to -f
option from terminal prompt right away, without using search through manpage.
Command Line – Get Paragraph for Certain Option of Command
command linedocumentationmanpage
command linedocumentationmanpage
For example instead of whole manual of apt-get
I want jump to -f
option from terminal prompt right away, without using search through manpage.
Best Answer
The default pager used by
man
isless
. You can pass the ERE (Extended Regular Expression) search pattern thatless
understands directly to it via theLESS
environment variable, in you case the following should do:This is exactly same as passing
/-f
after doingman apt-get
.Now, this would highlight all
-f
s in theman
page, to jump straight to the desired one i.e. option-f
, you can leverage ERE to match only the lines that start with spaces/tabs, followed by-f
:Although this would do here but still might not be precise for all pages, as this will match anything that starts with
-f
after initial spaces/tabs. Tweak the pattern a bit to meet you need in those cases.You can create a tiny function to pass the search pattern and the
man
page to look for as arguments, if you do this often.