I'm trying to find a command to search for a pattern containing hyphens inside all man pages.
I've looked at
man man, and found these 3 options:
Search for text in all manual pages. This is a brute-force search, and is likely to take some time; if you can, you should specify a section to reduce the number of pages that need to be searched. Search terms may be simple strings (the default), or regular expressions if the
--regexoption is used.
Don't actually display the manual pages, but do print the location(s) of the source nroff files that would be formatted.
List is a colon- or comma-separated list of order specific manual sections to search. This option overrides the
$MANSECTenvironment variable. (The
-sspelling is for compatibility with System V.)
I've tried to combine them to search for the pattern
mark-modified-lines which is a readline option described in
$ man -s1 -Kw mark-modified-lines
But it doesn't find any page:
No manual entry for mark-modified-lines
And the command exits with the code
I thought that maybe the syntax of the command was wrong, but it doesn't seem so, since this command correctly finds the 5 man pages on my system which contains the word
$ man -s1 -Kw guitar
I thought that maybe the hyphens in the word caused an issue.
man bash, I found the
--regex option which is described as follows:
Show all pages with any part of either their names or their descriptions matching each page argument as a regular expression, as with
apropos(1). Since there is usually no reasonable way to pick a "best" page when searching for a regular expression, this option implies
I tried to use this option and replace the word
mark-modified-lines with the regex
mark.modified.lines, where the hyphens are themselves replaced with the metacharacter
. which should match any character:
$ man -s1 -Kw --regex 'mark.modified.lines'
It still doesn't print any page, while I know that the text is written in the
bash man page.
. in the regex seems to be parsed as expected, since this command:
$ man -s1 -Kw --regex 'mark.mo'
And these 2 manpages (
xditview) are both matched by the regex
man x11perfcomp contains this line:
Mark Moraes wrote the original scripts to compare servers.
man xditview contains this line:
Mark Moraes (University of Toronto)
man -s1 -Kw --regex 'mark.mo' doesn't print the bash man page:
While I expected it would, since it contains this line:
Is it possible to search for a pattern containing hyphens inside the man pages?