2

I want to find all man pages for commands that begin with wh. But I do not understand why the following keyword does not work.

  man -f "wh"

Also if I put

  man chmod

in man page of chmod, it has the word "symbolic", so I put

  man -f "symbolic"

but chmod command does not show up in the results.

In short, how do I find/search commands or command description by inside-word contents? I know how to find a certain words after I get the man page, using / character, but I want to find all man pages with the search word.

1

You can use the -k switch to find all the man pages that contain wh in either their name or their short descriptions. Then just grep for the ones that start with wh. The command apropos is equivalent to man -k.

Example

$ man -k wh | grep "^wh"
what (1p)            - identify SCCS files (DEVELOPMENT)
whatis (1)           - display manual page descriptions
whereis (1)          - locate the binary, source, and manual page files for a command
which (1)            - shows the full path of (shell) commands.
while (n)            - Execute script repeatedly as long as a condition is met
whiptail (1)         - display dialog boxes from shell scripts
whirlwindwarp (6x)   - crazy moving stars
whline (3x)          - create curses borders, horizontal and vertical lines
whline_set (3x)      - create curses borders or lines using complex characters and renditions
who (1)              - show who is logged on
who (1p)             - display who is on the system
whoami (1)           - print effective userid
whois (1)            - client for the whois service

Searching through the man pages

If you're determined to search through the man pages doing a full text search you can use the -K switch. That's an uppercase K.

Example

$ man -w -K symbolic | head -10
/usr/local/share/man/man1/mimeopen.1
/usr/local/share/man/man1/mimetype.1
/usr/local/share/man/man1/ptksh.1
/usr/share/man/man1/as.1.gz
/usr/share/man/man1/atop.1.gz
/usr/share/man/man1/atopsar.1.gz
/usr/share/man/man1/attr.1.gz
/usr/share/man/man1/autoreconf.1.gz
/usr/share/man/man1/bakefilize.1.gz
/usr/share/man/man1/bash.1.gz

This method doesn't give you the name of the man page nor the short description though. It only shows you the actual name of the file that the man page is stored in, which is typically the name of the command.

  • Thanks, how about man -k symbolic | grep "symbolic". chmod command still does not show up even if chmod man page contains the word symbolic – EPSILONsdfsdfdsf Oct 1 '13 at 4:56
  • 1
    @KeenanERNLDKNF This only looks at the names of the man pages, not their contents. Searching their contents would be far more costly. – Chris Down Oct 1 '13 at 5:09
  • @KeenanERNLDKNF - the option man -K ... will look through all the man pages but this is a full on scan through every file, so will run for a bit. – slm Oct 1 '13 at 5:16
  • @ChrisDown - I tried to explain that this looks through the name and the short description, is it not specified clear enough? – slm Oct 1 '13 at 5:17
  • It is extremely clear, I was talking to @KeenanERNLDKNF, it wasn't a comment on your answer (which I think is fine). – Chris Down Oct 1 '13 at 5:27
0

man -f wh (synonymous with whatis) displays the short (one-line) description for the command wh. The flag -f tells man to display only the first line and not the whole page. That's no what you're after.

The command apropos wh (synonymous with man -k wh) lists the man pages whose short description contains the string wh. If you want to combine a search in the short description with a pattern on the command name, you can filter the results of apropos with grep. To restrict to user commands (i.e. section 1) and not display administrator commands, C library functions, etc., pass -S 1. If you want both user and administrator commands, pass -S 1:8.

apropos symbolic | grep '^wh'

To search in whole man pages, with mandb (the most common man implementation on Linux), use -K (capital K, as opposed to the lowercase k for apropos). This can take a very long time if you have a lot of man pages installed; consider passing the --regex option to restrict the search to man pages whose one-line description matches a regex.

man -K -S 1:8 --regex 'change.*file' symbolic

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.