How to search a pattern containing hyphens inside man pages?
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
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:
-K
,--global-apropos
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--regex
option is
used.
-w
,--where
,--path
,--location
Don't actually display the manual pages, but do print the location(s) of the source nroff files that
would be formatted.
-S list
,-s list
,t--sections=list
List is a colon- or comma-separated list of order specific manual sections to search. This option
overrides the$MANSECT
environment variable. (The-s
spelling 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 bash
:
$ 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 16
.
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 guitar
:
$ man -s1 -Kw guitar
/usr/share/man/man1/ffmpeg-all.1.gz
/usr/share/man/man1/ffserver-all.1.gz
/usr/share/man/man1/ffplay-all.1.gz
/usr/share/man/man1/ffmpeg-filters.1.gz
/usr/share/man/man1/ffprobe-all.1.gz
I thought that maybe the hyphens in the word caused an issue.
In man bash
, I found the --regex
option which is described as follows:
--regex
Show all pages with any part of either their names or their descriptions matching each page argument
as a regular expression, as withapropos(1)
. Since there is usually no reasonable way to pick a
"best" page when searching for a regular expression, this option implies-a
.
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.
The metacharacter .
in the regex seems to be parsed as expected, since this command:
$ man -s1 -Kw --regex 'mark.mo'
Prints:
/usr/share/man/man1/x11perfcomp.1.gz
/usr/share/man/man1/xditview.1.gz
And these 2 manpages (x11perfcomp
, xditview
) are both matched by the regex mark.mo
.
More specifically, man x11perfcomp
contains this line:
Mark Moraes wrote the original scripts to compare servers.
^^^^^^^
And man xditview
contains this line:
Mark Moraes (University of Toronto)
^^^^^^^
However, man -s1 -Kw --regex 'mark.mo'
doesn't print the bash man page:
/usr/share/man/man1/bash.1.gz
While I expected it would, since it contains this line:
mark-modified-lines (Off)
^^^^^^^
Is it possible to search for a pattern containing hyphens inside the man pages?
man
add a comment |Â
up vote
2
down vote
favorite
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:
-K
,--global-apropos
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--regex
option is
used.
-w
,--where
,--path
,--location
Don't actually display the manual pages, but do print the location(s) of the source nroff files that
would be formatted.
-S list
,-s list
,t--sections=list
List is a colon- or comma-separated list of order specific manual sections to search. This option
overrides the$MANSECT
environment variable. (The-s
spelling 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 bash
:
$ 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 16
.
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 guitar
:
$ man -s1 -Kw guitar
/usr/share/man/man1/ffmpeg-all.1.gz
/usr/share/man/man1/ffserver-all.1.gz
/usr/share/man/man1/ffplay-all.1.gz
/usr/share/man/man1/ffmpeg-filters.1.gz
/usr/share/man/man1/ffprobe-all.1.gz
I thought that maybe the hyphens in the word caused an issue.
In man bash
, I found the --regex
option which is described as follows:
--regex
Show all pages with any part of either their names or their descriptions matching each page argument
as a regular expression, as withapropos(1)
. Since there is usually no reasonable way to pick a
"best" page when searching for a regular expression, this option implies-a
.
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.
The metacharacter .
in the regex seems to be parsed as expected, since this command:
$ man -s1 -Kw --regex 'mark.mo'
Prints:
/usr/share/man/man1/x11perfcomp.1.gz
/usr/share/man/man1/xditview.1.gz
And these 2 manpages (x11perfcomp
, xditview
) are both matched by the regex mark.mo
.
More specifically, man x11perfcomp
contains this line:
Mark Moraes wrote the original scripts to compare servers.
^^^^^^^
And man xditview
contains this line:
Mark Moraes (University of Toronto)
^^^^^^^
However, man -s1 -Kw --regex 'mark.mo'
doesn't print the bash man page:
/usr/share/man/man1/bash.1.gz
While I expected it would, since it contains this line:
mark-modified-lines (Off)
^^^^^^^
Is it possible to search for a pattern containing hyphens inside the man pages?
man
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
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:
-K
,--global-apropos
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--regex
option is
used.
-w
,--where
,--path
,--location
Don't actually display the manual pages, but do print the location(s) of the source nroff files that
would be formatted.
-S list
,-s list
,t--sections=list
List is a colon- or comma-separated list of order specific manual sections to search. This option
overrides the$MANSECT
environment variable. (The-s
spelling 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 bash
:
$ 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 16
.
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 guitar
:
$ man -s1 -Kw guitar
/usr/share/man/man1/ffmpeg-all.1.gz
/usr/share/man/man1/ffserver-all.1.gz
/usr/share/man/man1/ffplay-all.1.gz
/usr/share/man/man1/ffmpeg-filters.1.gz
/usr/share/man/man1/ffprobe-all.1.gz
I thought that maybe the hyphens in the word caused an issue.
In man bash
, I found the --regex
option which is described as follows:
--regex
Show all pages with any part of either their names or their descriptions matching each page argument
as a regular expression, as withapropos(1)
. Since there is usually no reasonable way to pick a
"best" page when searching for a regular expression, this option implies-a
.
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.
The metacharacter .
in the regex seems to be parsed as expected, since this command:
$ man -s1 -Kw --regex 'mark.mo'
Prints:
/usr/share/man/man1/x11perfcomp.1.gz
/usr/share/man/man1/xditview.1.gz
And these 2 manpages (x11perfcomp
, xditview
) are both matched by the regex mark.mo
.
More specifically, man x11perfcomp
contains this line:
Mark Moraes wrote the original scripts to compare servers.
^^^^^^^
And man xditview
contains this line:
Mark Moraes (University of Toronto)
^^^^^^^
However, man -s1 -Kw --regex 'mark.mo'
doesn't print the bash man page:
/usr/share/man/man1/bash.1.gz
While I expected it would, since it contains this line:
mark-modified-lines (Off)
^^^^^^^
Is it possible to search for a pattern containing hyphens inside the man pages?
man
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:
-K
,--global-apropos
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--regex
option is
used.
-w
,--where
,--path
,--location
Don't actually display the manual pages, but do print the location(s) of the source nroff files that
would be formatted.
-S list
,-s list
,t--sections=list
List is a colon- or comma-separated list of order specific manual sections to search. This option
overrides the$MANSECT
environment variable. (The-s
spelling 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 bash
:
$ 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 16
.
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 guitar
:
$ man -s1 -Kw guitar
/usr/share/man/man1/ffmpeg-all.1.gz
/usr/share/man/man1/ffserver-all.1.gz
/usr/share/man/man1/ffplay-all.1.gz
/usr/share/man/man1/ffmpeg-filters.1.gz
/usr/share/man/man1/ffprobe-all.1.gz
I thought that maybe the hyphens in the word caused an issue.
In man bash
, I found the --regex
option which is described as follows:
--regex
Show all pages with any part of either their names or their descriptions matching each page argument
as a regular expression, as withapropos(1)
. Since there is usually no reasonable way to pick a
"best" page when searching for a regular expression, this option implies-a
.
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.
The metacharacter .
in the regex seems to be parsed as expected, since this command:
$ man -s1 -Kw --regex 'mark.mo'
Prints:
/usr/share/man/man1/x11perfcomp.1.gz
/usr/share/man/man1/xditview.1.gz
And these 2 manpages (x11perfcomp
, xditview
) are both matched by the regex mark.mo
.
More specifically, man x11perfcomp
contains this line:
Mark Moraes wrote the original scripts to compare servers.
^^^^^^^
And man xditview
contains this line:
Mark Moraes (University of Toronto)
^^^^^^^
However, man -s1 -Kw --regex 'mark.mo'
doesn't print the bash man page:
/usr/share/man/man1/bash.1.gz
While I expected it would, since it contains this line:
mark-modified-lines (Off)
^^^^^^^
Is it possible to search for a pattern containing hyphens inside the man pages?
man
man
edited 55 mins ago
asked 1 hour ago
user938271
14417
14417
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
5
down vote
accepted
man -K
searches the source code of the manual pages, not their rendered form (as displayed by man
). Hyphens are encoded -
, so you need to search for that:
man -s1 -Kw 'mark-mo'
(Yes, this is rather obscure.)
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
man -K
searches the source code of the manual pages, not their rendered form (as displayed by man
). Hyphens are encoded -
, so you need to search for that:
man -s1 -Kw 'mark-mo'
(Yes, this is rather obscure.)
add a comment |Â
up vote
5
down vote
accepted
man -K
searches the source code of the manual pages, not their rendered form (as displayed by man
). Hyphens are encoded -
, so you need to search for that:
man -s1 -Kw 'mark-mo'
(Yes, this is rather obscure.)
add a comment |Â
up vote
5
down vote
accepted
up vote
5
down vote
accepted
man -K
searches the source code of the manual pages, not their rendered form (as displayed by man
). Hyphens are encoded -
, so you need to search for that:
man -s1 -Kw 'mark-mo'
(Yes, this is rather obscure.)
man -K
searches the source code of the manual pages, not their rendered form (as displayed by man
). Hyphens are encoded -
, so you need to search for that:
man -s1 -Kw 'mark-mo'
(Yes, this is rather obscure.)
answered 52 mins ago
Stephen Kitt
152k23337405
152k23337405
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477084%2fhow-to-search-a-pattern-containing-hyphens-inside-man-pages%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password