Previous Table of Contents Next


Module 5
apropos (BSD)

DESCRIPTION

The external apropos command searches for keywords in the header lines of all UNIX Reference Manual entries. There is one manual entry for each UNIX command distributed with your system. These entries are often referred to as "man pages." The header line for each command entry is a brief one-line description of the command.

If you need to use a command but do not know its name, you can use apropos to search for the command by specifying keywords. You specify keywords on the apropos command line. Each keyword is searched for separately in the header lines of all manual entries. If a keyword is located in the title (header line) of a man page, the command's title is displayed. The search ignores the case of letters.

A match occurs even if the keyword is a part of a word in the title. For example, if you specify

   apropos command

all titles with the word "command" and "commands" would be displayed.

COMMAND FORMAT

Following is the general format of the apropos command.

   apropos keyword [ ... ]

Arguments

The following list describes the arguments that may be passed to the apropos command.

keyword A word you want to search for in the title of all the manual sections.

FURTHER DISCUSSION

The apropos command is the same as the man -k keyword command. If apropos displays a line for a keyword that begins with name(section) ..., you can display the entire manual page by entering the command:

   man section name

To display the title line of each manual page that contains the keyword "editor" you specify a apropos command like:

   apropos editor

which should return the following output:

   a,out (5)         - assembler and link editor output format
   ed, red (1)       - basic line editor
   ex, edit (1)      - line editor
   ld (1)            - link editor
   sed (1)           - stream text editor
   vi, view (1)      - visual display editor based on ex(1)

The output from your system may vary depending on which utilities have been implemented and installed on your particular system.

DIAGNOSTICS AND BUGS

If apropos fails to work, it is possible the /usr/lib/whatis file has not been created. The system administrator creates this file by changing directories to /usr/lib and executing mkwhatis or makewhatis, depending on your system';s command name.

RELATED COMMANDS

Refer to the man and whatis commands described in modules 87 and 155.

RELATED FILES

The apropos command looks in a file containing the titles for all of the manual documents, usually the /usr/lib/whatis.

APPLICATIONS

The apropos command provides a way for you to search for a command to perform a certain function based on keywords. For example, if you needed to display the contents of a file, you could use apropos and specify several keywords that referred to displaying contents of files. For example, you might try the command,

   apropos print display show type file

The trick to making apropos work is being flexible in your choice of keywords. Flexible means you should try to remember as many synonyms for a word as you can.

There are trade-offs in how you use keywords. If you use too many or too broad of a word, such as file, you may get pages of output. On the other hand, if you use a very selective set of keywords, you may get no output. The basic advice is to try a few different keywords to get the general idea of how the titles of the man pages are written. Unfortunately, experience is still the best teacher, especially when UNIX man pages are involved.

TYPICAL OPERATION

In this activity you use the apropos command to locate commands related to text. Begin at the shell prompt.

1.  Type apropos text and press Return. Depending on your system, the output should resemble the following:
   cj> apropos text
   nawk(1)                - text pattern scanning and processing language
   csplit(1)              - context split
   ed, red (1)            - text editor
   edit(1)                - text editor (variant of ex for casual users)
   end, etext, edata(3C)  - last locations in program
   ex(1)                  - text editor
   fspec(4)               - format specification in text files
   lex(1)                 - generate programs for lexical analysis of text
   neqn(1)                - format mathematical text for nroff
   nroff(1)               - format text
   plock(2)               - lock process, text, or data in memory
   sed(1)                 - stream text editor
2.  Turn to Module 65 to continue the learning sequence.


Previous Table of Contents Next