Search Man Pages

You need to use the following commands to search man pages:

apropos Command

The apropos command searches a set of database files containing short descriptions of system commands for keywords and shows the result on the screen. The syntax is as follows:

 
apropos keyword
apropos "string or phrase"
apropos -s 1 delete

apropos Command Examples

To Search command / functions related to compare operation, enter:

$ apropos compare

Sample outputs:

[ (1)                - check file types and compare values
bcmp (3)             - compare byte sequences
bzcmp (1)            - compare bzip2 compressed files
bzdiff (1)           - compare bzip2 compressed files
cmp (1)              - compare two files byte by byte
comm (1)             - compare two sorted files line by line
compare (1)          - mathematically and visually annotate the difference between an image and its reconstruction.
diff (1)             - compare files line by line
diff3 (1)            - compare three files line by line
git-diff-files (1)   - Compares files in the working tree and the index
git-diff-index (1)   - Compares content and mode of blobs between the index and repository
git-diff-tree (1)    - Compares the content and mode of blobs found via two tree objects
infocmp (1)          - compare or print out terminfo descriptions
mcomp (1)            - Compares two files using mtools
memcmp (3)           - compare memory areas
msgcmp (1)           - compare message catalog and template
ndiff (1)            - Utility to compare the results of Nmap scans
ntfscmp (8)          - compare two NTFS filesystems and tell the differences
pthread_equal (3)    - compare thread IDs
strcasecmp (3)       - compare two strings ignoring case
strcmp (3)           - compare two strings
strcoll (3)          - compare two strings using the current locale
strncasecmp (3)      - compare two strings ignoring case
strncmp (3)          - compare two strings
strverscmp (3)       - compare two version strings
test (1)             - check file types and compare values
wcscasecmp (3)       - compare two wide-character strings, ignoring case
wcscmp (3)           - compare two wide-character strings
wcsncasecmp (3)      - compare two fixed-size wide-character strings, ignoring case
wcsncmp (3)          - compare two fixed-size wide-character strings
wmemcmp (3)          - compare two arrays of wide-characters
xzcmp (1)            - compare compressed files
xzdiff (1)           - compare compressed files
zcmp (1)             - compare compressed files
zdiff (1)            - compare compressed files

Task: Search For a String

Search command to remove a file, enter:

$ apropos "remove file"

Sample outputs:

rm                   (1)  - remove files or directorie

Task: Search Specific Section of The Man Page

To search only the given manual section use the -s option:

apropos -s 1 compare

Sample outputs:

[ (1)                - check file types and compare values
bzcmp (1)            - compare bzip2 compressed files
bzdiff (1)           - compare bzip2 compressed files
cmp (1)              - compare two files byte by byte
comm (1)             - compare two sorted files line by line
compare (1)          - mathematically and visually annotate the difference between an image and its reconstruction.
diff (1)             - compare files line by line
diff3 (1)            - compare three files line by line
git-diff-files (1)   - Compares files in the working tree and the index
git-diff-index (1)   - Compares content and mode of blobs between the index and repository
git-diff-tree (1)    - Compares the content and mode of blobs found via two tree objects
infocmp (1)          - compare or print out terminfo descriptions
mcomp (1)            - Compares two files using mtools
msgcmp (1)           - compare message catalog and template
ndiff (1)            - Utility to compare the results of Nmap scans
test (1)             - check file types and compare values
xzcmp (1)            - compare compressed files
xzdiff (1)           - compare compressed files
zcmp (1)             - compare compressed files
zdiff (1)            - compare compressed files

Task: Regex Based Search

You can force apropos to interpret each keyword as a regular expression using the -r option:

$ apropos -r scanf

Sample outputs:

fscanf (3)           - input format conversion
scanf (3)            - input format conversion
sscanf (3)           - input format conversion
Video::DVDRip::CPAN::Scanf (3pm) - emulate sscanf() of the C library
vfscanf (3)          - input format conversion
vscanf (3)           - input format conversion
vsscanf (3)          - input format conversion

The ‘man -K’ Command

The -K option is passed to the man command to search for the specified string in all man pages. The syntax is as follows:

 
man -K keyword
man -K "string or phrase"

Search all man pages for fopen word, type:

$ man -K "fopen"

Output:

/usr/share/man/en/man3/fclose.3.gz? [ynq]

Type y to open/display man page, n to continue search, q to Quit search. This is a brute-force search, and is likely to take some time. So it helps to specify a man page section (1-7) using the following syntax:

$ man -s 3 -K "open"

OR

$ man -s 8 -K "user"

Please note that above commands also works with other UNIX and *BSD like oses