The apropos linux command

By default, the apropos command, searches the mandb database, keys and values, in a case insensitive way, using regular expressions.

bind -> "- 2 2 1557252946 0 A - - gz bind a name to a socket"
..
# The database, that apropos searches
# in, contains keys and values.
#    key -> value 
#  item name -> description
# key is the name of a user
# command, or of a system or a 
# library call...
# value, is the description,
# of this user command, or of
# this system, or library call. 
# value additionally contains, 
# the manual section, to which
# the item belongs. 
# By default apropos will search 
# the key and value for a match
# using regular expression.

This is the same as if apropos is used, with the -r option.

debian:~$ apropos newline
# apropos searches the name and 
# the description, in the mandb
# database, for a provided token
# by using regular expressions.
# Partial matching is allowed.
rtpr (8)             - replace backslashes with newlines.
wc (1)               - print newline, word, and byte counts for eac...    

As seen from the previous example, apropos will truncate the output, to fit the terminal width, as such the -l option can be used, if the full output is to be shown.

debian:~$ apropos newline
# With regards to the newline token, 
# what are the commands, system calls, 
# library functions.... that are 
# available, so what kind of 
# documentation do we have?
rtpr (8)             - replace backslashes with newlines.
wc (1)               - print newline, word, and byte counts for eac...

debian:~$ apropos -l newline
# As seen from the previous example, 
# the output is truncated, to fit the
# terminal width, so the -l option can
# be used to have full output display.
rtpr (8)             - replace backslashes with newlines.
wc (1)               - print newline, word, and byte counts for each file

Manual sections to search in, can be specified by using the -s option, where -s is followed by one or more manual section, separated by commas.

debian:~$ apropos -s 3,7 'regex'
# Search section 3 of the manual, 
# which is related to library 
# functions, and section 7, which 
# is related to miscellaneous subjects, 
# for the regex token. 
re_comp (3)          - BSD regex functions
regex (7)            - POSIX.2 regular expressions
...                

apropos can be used to search for multiple tokens, each token is searched for, and the name and description of the command, or system call, or… that each token matches, is printed on screen.

If instead, what is preferred, is that results contain all tokens, the -a option can be used.

debian:~$ apropos -s 1 copy move 
# with regards to the tokens 
# copy or move,  in section one
# of the manual, what are the user 
# commands that we have ? 
colrm (1)            - remove columns from a file
cp (1)               - copy files and directories
...


debian:~$ apropos -a copy move
# apropos will search for the copy 
# token.
# apropos will search for the move 
# token.
# The results that matched the copy
# or move tokens, are returned. 
# -a will display only the results, 
# that matched both the copy and 
# move tokens. 
memmove (3)          - copy memory area
wmemmove (3)         - copy an array of wide-characters


debian:~$ apropos -s 1 'copy move'
# search the mandb database, for the 
# pattern 'copy move' and not for 
# the pattern 'copy', or the pattern 
# 'move' .
copy move: nothing appropriate.               

When the -w option is used, regular expression matching is not used, but instead, a token can contain shell wildcards, such as *, or ?. In this case the token after expansion, must match the name fully, or it can match the description on word boundaries.

Additionally --exact can be used with the -w option, in this case the token after expansion, must fully match the name or the description.

debian:~$ apropos -s 1 move
# When regex search is used, a token 
# can partially match the name, or the
# description in the mandb database. 
# move is found in remove, gvfs-move, 
# move...
colrm (1)            - remove columns from a file
gvfs-move (1)        - (unknown subject)
mv (1)               - move (rename) files
...


debian:~$ apropos -s 1 -w  move
# When the -w option is used, the 
# token after expansion, must fully
# match the name, or it can match 
# the description on word boundaries,
# in the mandb database. 
# move is expanded to move
mv (1)               - move (rename) files


debian:~$ apropos -s 1 -w --exact 'move'
# When --exact is used with the -w
# option, the token after expansion,
# must fully match the name or the 
# description in the mandb database.
move: nothing appropriate.


debian:~$ apropos -s 1 -w  '*move'
# shell style wildcards as in * or 
# ? can be used with the -w option. 
# * will match 0 or more characters,  
# ? match any one character.
# The token after expansion must match 
# the name fully, or it must match the 
# description on word boundaries.
# *move after expansion, can be for 
# example remove, gvfs-move ..
colrm (1)            - remove columns from a file
gvfs-move (1)        - (unknown subject)
....

Finally the -e option, can be used to match a token, on word boundaries, in the mandb database, name or description fields.

debian:~$ apropos -r -s1,3 clean
# Search using regular expression 
# for the clean token. 
# clean will match: cleanup, clean, 
# hp-clean, Cleaning, pthread_cleanup_pop 
# ...
dbus-cleanup-sockets (1) - clean up leftover sockets in a directory
hp-clean (1)         - Printer Printhead Cleaning Utility
...

debian:~$ apropos -s 1,3  -e 'clean'
# The -e option, matches exactly the
# token, on word boundaries, in the 
# name or in the description fields.
dbus-cleanup-sockets (1) - clean up leftover sockets in a directory