linux 用了这么多年,我发现我 man 手册还不会用。
我想查询 find 命令的正则表达式类型-regextype 选项的参数有哪些,man 手册介绍如下:
-regextype type
Changes the regular expression syntax understood by -regex and -iregex tests which occur later on the command line. To see which regular expression types are known, use -regextype help. The Texinfo documentation (see SEE ALSO) explains the meaning of and differences between the various types of regular expression.
其中-regextype help 是粗体的,所以我以为是告诉我使用
find -regextype help
命令,就能看到已知的正则表达式类型,但是我敲这个命令后,终端却提示我:
find -regextype help
find: Unknown regular expression type ‘help’; valid types are ‘findutils-default’, ‘awk’, ‘egrep’, ‘ed’, ‘emacs’, ‘gnu-awk’, ‘grep’, ‘posix-awk’, ‘posix-basic’, ‘posix-egrep’, ‘posix-extended’, ‘posix-minimal-basic’, ‘sed’.
help 是未知的参数,说明这个用法是错误的,虽然后面的提示告诉了我可以使用哪些参数,但 man 手册的原意肯定是通过 help 来获取详细正则表达式类型及其介绍的。
请问如果我想了解-regextype 后面的参数有哪些,及那些参数的含义,我该如何查找?
1
lxilu 2021-02-13 00:05:15 +08:00 via iPhone
这不告诉你了吗
|
2
lxilu 2021-02-13 00:06:36 +08:00 via iPhone
The Texinfo documentation (see SEE ALSO) explains the meaning of and differences between the various types of regular expression.
|
3
omph 2021-02-13 00:10:05 +08:00
( see SEE ALSO )
最下面的备注里有解释 |
4
lolcat OP @lxilu 谢谢,我看 SEE ALSO 部分用 info find 命令找到正则表达式类型了。请问 man 手册中的-regextype help 粗体字有啥含义? man 手册为啥要我使用-regextype help ?
|
5
lolcat OP @omph 谢谢,我看 SEE ALSO 部分用 info find 命令找到正则表达式类型了。请问 man 手册中的-regextype help 粗体字有啥含义? man 手册为啥要我使用-regextype help ?
|
6
lxilu 2021-02-13 00:18:59 +08:00 via iPhone
应该只是占位
|
7
zlowly 2021-02-13 00:35:14 +08:00 1
看 find 的源码里,只要 regextype 后的参数没有匹配到已知类型,就会报错。其中源码里的那段代码注释是
We didn't find a match for the type of regular expression that the user indicated they wanted. Tell them what the options are. 所以理论上只要 regextype 后用任何非已知类型都能得到一样的信息,man 手册里可能只是为了用户方便记忆建议用 help 作为参数而已,无需做过多解读。 |
8
asahui 2021-02-13 09:13:09 +08:00
只是单纯英文问题,其实这里的加粗而且不是像 markdown 里的`code` 这样,就是单纯提配你——去看-regextype 的 help,这里的 help 就是文档的意思,这句话不是叫你打`-regextype help`,而是查`-regextype`的 help
|
9
omph 2021-02-14 00:17:59 +08:00
linux 是个自由的世界,包括命令的格式
|
10
feedcode 2021-02-14 19:01:22 +08:00 1
恭喜你找到了一个文档的 bug,文档和行为不匹配
|
11
feedcode 2021-02-14 19:09:28 +08:00 1
|
12
lolcat OP @feedcode 请问你这看的网页是 info find 显示的结果吧?在哪看 4.8 版本的 man find 显示的结果?
|
13
feedcode 2021-02-15 21:21:28 +08:00 1
good question.
网页是从 doc/find.texi 生成的 ( Texinfo is the official documentation format of the GNU project ) http://www.gnu.org/software/texinfo/manual/texinfo/texinfo.html#Adding-Output-Formats > From time to time, proposals are made to generate traditional Unix man pages from Texinfo source. However, because man pages have a strict conventional format, creating a good man page requires a completely different source from that needed for the typical Texinfo applications of writing a good user tutorial and/or a good reference manual. This makes generating man pages incompatible with the Texinfo design goal of not having to document the same information in different ways for different output formats. You might as well write the man page directly. find 的 man 应该是 https://git.savannah.gnu.org/cgit/findutils.git/plain/find/find.1 , 里面还是过时的信息,:( |
14
IgniteWhite 2021-02-17 21:42:29 +08:00 via iPhone
@feedcode 感谢。我看了这个帖子觉得楼主问的问题是有道理的,我也理解不了。楼上为文档的小错误辩解,我还以为我不会阅读了……
|