Example: I am using tar -zxvf command but I don't know what 'x' stands for.
How can I check this single parameter without having to scroll all the way through man tar?
x is for extract.
After you are inside man, type /-xenter to search info about the -x parameter,
Press n to jump to the next -x match, and N for the previous
For large man pages, or a common terms, a little regex can be used to narrow the search.
If you just want the main entry, you can use /^ *-x to remove most extraneous matches.
This works as most man pages are formatted with the entry indented with spaces.
^ * matches the start of line, with zero to many spaces.-x is the search string.You could also grep it out of the man page with some context:
man tar | grep -C5 -- '-x\b'
If you use Emacs, M-x man RET tar, then C-s -x.
Hit C-s repeatedly until you get to the right place, then hit return.
C-r is the same, but backwards. (But both will wrap on a double strike at document top/bottom.)
Also, in cases like this (man page search), case sensitive search is preferable. Examine the case-fold-search variable.
The huge advantage of using your editor to view man pages is that you know all commands so well - navigation, copying, everything you'd like to do, you already know how.
I usually do this
man tar | less -p ' -x'
If the pattern is found, less will start the page with it, the pattern here is 3 spaces before the parameter you are searching for. Not 100% reliable but usually works.
If the pattern is not found, then pressing enter will show the whole result, and then u can use less search functionality itself to search for the argument.
I know that it's a bit old question so sorry for reviving but I've written this simple shell script that you can use:
function manopt() {
mn=`man -P cat $1`
for i in ${@:2}
do
echo $mn | grep --color=always -A5 "^ *$i" | sed -En '/^$/q;p'
done
}
Use it for example as:
➜ manopt ls -l -a
-l use a long listing format
-a, --all
do not ignore entries starting with .
Note that you can have as many arguments as you like but they have to be valid ones (and at the start of the line).
In general, I just use that man(1) shows the formatted page using your favorite pager, at least more(1), and in the (rather rigid) manpage format flag -x is described under -x, so a quick search rapidly zeroes in on that.
If if is a GNU program (or at least one with an info document), an info viewer (like the builtin one in emacs(1) or the standalone pinfo(1)) are a comfortable way of browsing the mandatory Invoking section, with full detail of how the program is called. Again, search is available.