LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Exact Keyword Search within Man Pages? (https://www.linuxquestions.org/questions/linux-newbie-8/exact-keyword-search-within-man-pages-908083/)

kingisw 10-13-2011 10:59 PM

Exact Keyword Search within Man Pages?
 
Noob question...

How do you perform an exact keyword (case sensitive, the whole word only) search within a man page (say, "man bash")?

I know you can perform a generic search by pressing "/" and typing in the keyword.

Gracias

neonsignal 10-14-2011 08:41 AM

You can use the '\b' to match word boundaries in the search expression, eg
Code:

/\bor\b
will search for the word "or" as a standalone word (case sensitive).

David the H. 10-14-2011 09:39 AM

Note that what you're really doing here is using your pager's search function. By default most distributions use less as the display program for man pages. Hitting 'h' when inside less will bring up its help page.

less' search feature uses regular expressions by default. According to the help page, hitting ctrl+R just after calling up the search field will turn this off.

Of course you can also just format your regex so that it only matches what you want, as neonsignal demonstrated. Learning how to use regular expressions effectively is one of the most useful skills to have, as they are supported by so many programs.


This is a pretty good regular expressions tutorial:
http://www.grymoire.com/Unix/Regular.html

i92guboj 10-14-2011 10:21 AM

As said by others, it comes down to the pager you use. That's usually 'less' ('more' in ancient OSes).

But if you are more happy using GUIs or something else it can be done as well. You can just google for your man page and then use the search function in your browser, or use the kde man:// ioslave, etc. As always, there are lots of alternatives...

PTrenholme 10-14-2011 01:44 PM

Not exactly what you asked, but you might want to look at the -k and -K options of the man command. I find those quite useful when I want to find a command that does something, but I don't know which command to use.


All times are GMT -5. The time now is 09:39 PM.