50.3 apropos on Systems Without aproposI was just asked to write an article about how to simulate apropos on systems that don't have it. I have to confess that I've never faced this problem. But I was able to come up with a solution. Your mileage may vary - particularly since different UNIX implementations have different ways of storing their manual pages.
The solution has two parts.
First, you need a script that builds an
index; that's better than
grep
ping through every manual page in the
world.
[
Not always (
50.6
)
.
This script goes through every directory in which manual pages are stored. It strips all suffixes from the filenames, and then uses man to print the actual manual page. This is better than trying to look at the raw manual pages themselves because some vendors don't provide the raw manual pages. If you let man give you the page you want, you'll always find it. [2] The col command strips out boldfacing, underlining, and other monstrosities that will confuse grep . Finally, egrep looks for lines to put in the index. It's not as fussy as the BSD catman program (which mkindex is emulating), so it will find a fair number of lines that don't belong; but we think this is only a mild flaw.
Before you can use this script you'll have to substitute definitions for three variables:
Expect manindex to run for a long time; several minutes or more, depending on how thorough you want to be. Fortunately, you don't need to do this very often: once to get started, and then once a month (or so) to pick up any "stray" manual pages that someone else may have added. If you want to speed the task up, remember that you can skip any sections of the manual that you're not interested in by defining manlist appropriately. For example, if you're not interested in section 2 of the manual, just leave cat2 out of the list. Once you've created the index, the rest of the problem is easy. Just make yourself an apropos alias ( 10.2 ) and add it to your .cshrc file:
alias apropos "grep -i \!$ /home/mike/manindex.txt" Here's what its output looks like:
% As I pointed out, this isn't perfect. But I think it's a reasonable substitute. - |
|