How to install Linux compatible apropos
When I try to get information about apropos
, I get the following:
$ which apropos
/usr/bin/apropos
$ apropos --version
apropos from man-1.6g
I tried apropos -r '^report
but I get an error:
$ apropos -r '^report'
apropos: -r: unknown option
The man
page about apropos is very simple:
apropos(1) apropos(1)
NAME
apropos - search the whatis database for strings
SYNOPSIS
apropos keyword ...
DESCRIPTION
apropos searches a set of database files containing short descriptions of system commands for key-
words and displays the result on the standard output.
...
The above command works on Ubuntu/Linux.
I am not sure if it is because of the macOS apropos
BSD?
Is there any way I can install Linux compatible apropos
?
On Ubuntu/Multipass, I get the following. The man
page has all options:
ubuntu@shin-instance:~$ which apropos
/usr/bin/apropos
ubuntu@shin-instance:~$ apropos --version
apropos 2.9.1
$ man apropos
APROPOS(1) Manual pager utils APROPOS(1)
NAME
apropos - search the manual page names and descriptions
SYNOPSIS
apropos [-dalv?V] [-e|-w|-r] [-s list] [-m system[,...]] [-M path] [-L locale] [-C file] keyword ...
DESCRIPTION
Each manual page has a short description available within it. apropos searches the descriptions for in‐
stances of keyword.
...
OPTIONS
-d, --debug
Print debugging information.
-v, --verbose
Print verbose warning messages.
-r, --regex
Interpret each keyword as a regular expression. This is the default behaviour. Each keyword will be
matched against the page names and the descriptions independently. It can match any part of either.
The match is not limited to word boundaries.
-w, --wildcard
...
No, it does not have to do with macOS having a "BSD apropos" and Linux having a "Linux apropos".
Apropos on Linux and macOS is actually the exact same program. The difference you're seeing here is that macOS comes with a rather old version of apropros. You would find the exact same program in Linux distributions from that time period (at that time it was actually a rather simple shell script).
The "-r" option for regular expression was introduced with man-db version 2.5.4 from 2009, of which apropros is part.
You can install a newer version of man-db (and apropos) by having HomeBrew install, and running:
brew install man-db