apropos - macOS
Overview
The apropos
command in macOS is a useful tool for searching the man pages for entries that contain a given keyword. It scans the man page descriptions for instances of a specified term and displays the command names and short descriptions where the term appears. This command can be especially helpful when you’re trying to find a command or utility on a Unix-like system without knowing its exact name.
Syntax
The basic syntax for the apropos
command is:
apropos [options] keyword
Here, keyword
is the term you want to search for in the man pages. If the keyword is composed of multiple words, it should be enclosed in quotes.
Options/Flags
- -d, –debug: Show debugging information. Useful for diagnosing issues with the command.
- -e, –exact: Match exact words. The search will only return entries where the keyword is a complete word, not a substring.
- -l, –long: Use a long output format that will display a more detailed description of each matching command.
- -M path, –manpath=path: Specify an alternate set of colon-separated manual paths to search. If not provided,
apropos
uses the default manpath. - -m system[,…], –systems=system[,…]: Search man pages from other operating systems specified by
system
. - -r, –regex: Interpret the keyword as a regular expression. This allows for pattern searching within the man page descriptions.
- -s list, –sections=list: Search only the specified sections of the man pages. The list should be a comma-separated list of section numbers.
- -w, –wildcard: The keyword can contain wildcards (
*
for multiple characters and?
for a single character).
Examples
Search for any command related to “file”:
apropos file
Search for commands with the exact word “mkdir”:
apropos -e mkdir
Search for commands using a regular expression (e.g., start with “mk”):
apropos -r '^mk'
Search within a specific section of the man pages (e.g., section 1):
apropos -s 1 network
Common Issues
- No Matches Found: If
apropos
returns no results, ensure your spelling is correct, or try using synonyms or related terms. - Too Many Results: If you get too many irrelevant results, use the
-e
flag to narrow down to exact matches or the-r
flag to refine the search using a regular expression. - Issues with Manpath: If
apropos
cannot find any man pages, ensure that the MANPATH environment variable is set correctly or use the-M
option to specify a manual path.
Integration
apropos
can be used in combination with other commands to perform complex tasks. For example, to list all man pages related to “network” and then read them one after another:
apropos network | awk '{print $1}' | xargs man
Related Commands
- man: Display the user manuals for specified commands.
- whatis: Display one-line manual page descriptions.
- man -k: Equivalent to
apropos
.
For more detailed documentation, refer to the official macOS man pages or visit the online manual page resources.