Operating System - HP-UX
1847776 Members
3210 Online
104021 Solutions
New Discussion

Search keyword in "man" page

 
SOLVED
Go to solution
yyghp
Super Advisor

Search keyword in "man" page

When I use "man" to get help for the certain command, for example, "man swremove",
how can I search a string within all the man pages for "swremove"?
Something like with "vi", you can use "/" to search a specific string within the whole file.
Thanks!
15 REPLIES 15
Torsten.
Acclaimed Contributor

Re: Search keyword in "man" page

Vi-like search will work, but there are html-pages of the man pages too on http://docs.hp.com, e.g.

http://docs.hp.com/en/B2355-60103/index.html

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Pete Randall
Outstanding Contributor

Re: Search keyword in "man" page

Start by doing a man on "catman". That should get you going.


Pete

Pete
Torsten.
Acclaimed Contributor

Re: Search keyword in "man" page

... and on your server too per default:

http://yourserver.domain.com/cgi-bin/man2html

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
yyghp
Super Advisor

Re: Search keyword in "man" page

Thanks Torsten, the link is great!
But how can I use "vi-like search" in "man"? I tried to press "Esc",then "/", then , it didn't work.

Thanks Pete, but what do you mean "catman"?
TwoProc
Honored Contributor

Re: Search keyword in "man" page

First, try running "man -k swremove".

If it doesn't work, then as root, you'll need to kick off the command "catman".

Let that run till it's over (it will take a really long time).

Then, you can run "man -k swremove"

We are the people our parents warned us about --Jimmy Buffett
spex
Honored Contributor

Re: Search keyword in "man" page

I believe 'man' uses 'more' as its pager, so you're free to use any keystrokes that work in 'more'. As with vi, you can do / for a forward search, ? for a backward search, n to forward-repeat, and N to reverse-repeat.

PCS
Torsten.
Acclaimed Contributor

Re: Search keyword in "man" page

It works, your search string is anywhere on the page, but there is no highlighting. That's why I like to use a browser to read the man pages.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
yyghp
Super Advisor

Re: Search keyword in "man" page

Hi John,

In fact, I need to search a keyword within the manpage of "swremove", without going through all pages.
For example, I need to search for the option of "swremove": "enforce_dependencies", then I can go to those pages talking about "enforce_dependencies".

Thanks!
OldSchool
Honored Contributor

Re: Search keyword in "man" page

What I usually do is set and export the variable PAGER=pg. Man will then use "pg" for paging.

at the ":" you can enter "/top" to search for the characters "top" in the output
yyghp
Super Advisor

Re: Search keyword in "man" page

Thanks Torsten, but your link:
http://docs.hp.com/en/B2355-60103/index.html
is not a complete reference, I couldn't find even "swremove" in it.
Torsten.
Acclaimed Contributor
Solution

Re: Search keyword in "man" page

This is your start link:

http://docs.hp.com/en/hpuxman_pages.html

here is the man page for 11.11:

http://docs.hp.com/en/B2355-90692/swremove.1M.html

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
inventsekar_1
Respected Contributor

Re: Search keyword in "man" page

hi yyghp, i too had the same doubt just two or three days back.

just seeing ur post, i found out the way.

--------------------------------
search in man pages is equal to vi. but u should understand that, in vi to go to the command mode we should press ":" and for searching /string we will give.

but in man "forget that going to command mode" and remainings are same.
--------------------------------
or simply work like "more".
Be Tomorrow, Today.
Pete Randall
Outstanding Contributor

Re: Search keyword in "man" page

Searching within a single man page is just like in vi: enter the "/" character followed by the string you wish to search for - in your case "/enforce_dependencies".

To search all the man pages for a reference you need to run catman to generate the searchable database. This is described in the man pages for catman.


Pete

Pete
Bill Hassell
Honored Contributor

Re: Search keyword in "man" page

Finding any string in the man page description is done with man -k. man -k does a simple string match so man -k sw will find a lot of matches. The database needs to be built with catman (which will take a while), biut then it must be maintained. As new patches and applications are added, the man pages need to checked for new and changed items. catman -m will merge changed and added one-liners to the whatis database (/usr/share/lib/whatis).

On a new system, I'll start catman at the end of the day and then add something like this to cron:

# Update whatis (man -k) database
3 2 1,15 * * /usr/bin/catman -m

This runs the update on the 1st and 15th of each month. Then I just forget catman...

For searching inside man pages, the standard pager programs (pg, page, more) are just a bit too cryptic (and different). And of course, less is more. (there is a GNU program called less). So I wrote a script called viman (attached). Anytime I want a man page, I just type viman rather than man. It has the advantage of running a full vi with all the familiar commands like / and ? for searching, and G to jump down to the bottom. It also removes header lines and extra blank lines. When you're done reading, just type ZZ and the temp man page is gone.


Bill Hassell, sysadmin
Peter Nikitka
Honored Contributor

Re: Search keyword in "man" page

Hi,

I want to add something to Bills response:
Don't forget to set the MANPATH explicitly in your crontjob, because of the small environment of crontab. My example:
5 5 5,20 * * MANPATH=`cat /etc/MANPATH` catman -w

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"