any tips on efficient searching of man pages using grep / other commands

14 réponses [Dernière contribution]
PrimeOrdeal
Hors ligne
A rejoint: 09/15/2019

The man pages are great but can be quite long to search through by eye. Can anyone remind me of how to use any useful GNU/Linux commands (perhaps grep?) for searching the man pages automagically?

For instance I would like to search the man pages which would come up when typing "man sh" for a string such as "dummy" or "%k".

Any recommendations/suggestions?

Many thanks!

Azulavis
Hors ligne
A rejoint: 08/31/2020

type "man sh", press / key to enter search mode, type in search request and press Enter key, there is also "apropos" command but i dont understand how it works

PrimeOrdeal
Hors ligne
A rejoint: 09/15/2019

Great, that does it - many thanks!

Magic Banana

I am a member!

Hors ligne
A rejoint: 07/24/2010

Well, as 'man apropos' says:

apropos - search the manual page names and descriptions

You can try 'apropos search' for a meta-example (since it returns, among other results, apropos itself, because of the above description).

gaseousness
Hors ligne
A rejoint: 08/25/2020

up and down arrows scroll through previous searches, and n will find the next match of the search. q exits.

PrimeOrdeal
Hors ligne
A rejoint: 09/15/2019

Thanks!

gaseousness
Hors ligne
A rejoint: 08/25/2020

man less

should give a more complete list of shortcuts you could use

PrimeOrdeal
Hors ligne
A rejoint: 09/15/2019

Thanks. Can anyone tell me how to provide a filename which contains all of the man entries? Or do I need to pipe "man sh" into a file first? Or does less simply work on a data stream which is the one produced by "man sh"?

To cut a long question short - can anyone tell me what to type in order to use less for searching the output of "man sh" for the pattern "dummy" ("dummy" is just an example although its also a great album by Portishead)?

Azulavis
Hors ligne
A rejoint: 08/31/2020

when you type "man sh", j key scrolls down, k key scrolls up, after you use / key to search, n key move you to next search forwards, N key moves you to the previous search backwards. j and k keys are doing what less does, if i understand your question correctly, its what you want.

PrimeOrdeal
Hors ligne
A rejoint: 09/15/2019

Thanks, you are of course correct that this problem may be solved as described. I was just trying to beg an example on how to use "less" as an alternative.

Magic Banana

I am a member!

Hors ligne
A rejoint: 07/24/2010

I am not certain you understood that 'man' displays the manuals using 'less', by default.

Magic Banana

I am a member!

Hors ligne
A rejoint: 07/24/2010

The output of man can be piped. But, as you were told, you probably want to learn less' search features.

Magic Banana

I am a member!

Hors ligne
A rejoint: 07/24/2010

Neither "dummy" nor "%k" occur in the manual of dash.

PrimeOrdeal
Hors ligne
A rejoint: 09/15/2019

Thanks, I know; I established that already thanks to the search methods kindly provided previously. Therefore "dummy" is just a dummy variable in this example.

Azulavis
Hors ligne
A rejoint: 08/31/2020

Answer to this question: "Can anyone tell me how to provide a filename which contains all of the man entries?"

man -k .
- lists all man pages, with man section number in braces ()
man -k . -s 2
- lists all man pages in section 2
man -k . > manpages.txt
- saves list of names of manpages to a file