For example, if I enter the following command:
$ man -k compare
The diff command is missing from the results, however the test command is not. I get the same results using apropos as expected.
$ whereis diff
diff: /usr/bin/diff /usr/share/man/man1/diff.1.gz
$ whereis test
test: /usr/bin/test /usr/share/man/man1/test.1.gz
If I examine the short description of diff, it is the following:
NAME
GNU diff - compare files line by line
As you can clearly see, "compare" is in the short description. Moreover, let's examine the long description too:
DESCRIPTION
Compare FILES line by line.
And again, "Compare" appears in the description.
Now, let's examine the short description of test:
NAME
test - check file types and compare values
Which is what I would expect. However, "compare" is missing from the description of test.
So, I'm not clear why man -k compare or apropos compare do not find diff. However I believe it has to do with the output of the whatis command:
$ whatis diff
diff (1) - (unknown subject)
$ whatis test
test (1) - check file types and compare values
Now the reason for this discrepancy may be due to the fact that the man page for diff has a name that consists of two words "GNU diff" rather than one, but I'm not sure.