1

When should one use man and when man -k to check man pages? Whenever I'd like to check a man page I get confused with which one I should. Should I use this: man -k xyz or this: man xyz.

Some man pages are not found when we search using man, however that same page is found by man -k .

So please give an explanation when I should use man xyz or man -k xyz.

  • 2
    I suggest running man man and checking out what -k does. – Cristian Ciupitu Nov 22 '14 at 5:06
2

Doing a man man shows you what the -k switch does to man.

Using the -k switch

man -k printf
       Search  the  short descriptions and manual page names for the keyword 
       printf as regular expression.  Print out any matches.  Equivalent
       to apropos -r printf.

The tool, apropos mentioned above, searches through index files, looking at both the names of the man pages as well as a short description of each.

man apropos

Each manual page has a short description available within it.
apropos searches the descriptions for instances of keyword.

You can compare the 2 commands output, to convince yourself that they're doing the same things like so:

$ diff <(man -k printf) <(apropos -r printf)
$

Just man

Doing just a man xyz will search for a man page in the locations defined when you do a man -w.

Example
$ man -w
/usr/local/share/man:/usr/share/man

So when I type man xyz the man command will search through those directories, looking for a man page that corresponds to xyz.

Bottom line?

So man xyz is looking for man pages that correspond to the name xyz, while man -k xyz is looking for the string, "xyz" in both the names of the man pages along with the short description for each man page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.