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 后面的参数有哪些,及那些参数的含义,我该如何查找?
这不告诉你了吗
The Texinfo documentation (see SEE ALSO) explains the meaning of and differences between the various types of regular expression.
( see SEE ALSO )
最下面的备注里有解释
谢谢,我看 SEE ALSO 部分用 info find 命令找到正则表达式类型了。请问 man 手册中的-regextype help 粗体字有啥含义? man 手册为啥要我使用-regextype help ?
谢谢,我看 SEE ALSO 部分用 info find 命令找到正则表达式类型了。请问 man 手册中的-regextype help 粗体字有啥含义? man 手册为啥要我使用-regextype help ?
应该只是占位
看 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 作为参数而已,无需做过多解读。
只是单纯英文问题,其实这里的加粗而且不是像 markdown 里的`code` 这样,就是单纯提配你——去看-regextype 的 help,这里的 help 就是文档的意思,这句话不是叫你打`-regextype help`,而是查`-regextype`的 help
linux 是个自由的世界,包括命令的格式
恭喜你找到了一个文档的 bug,文档和行为不匹配
查了下最新的 4.8.0, 文档已经修正了
https://git.savannah.gnu.org/cgit/findutils.git/plain/doc/find.texi
http://www.gnu.org/software/findutils/manual/html%5Fmono/find.html#Full-Name-Patterns
请问你这看的网页是 info find 显示的结果吧?在哪看 4.8 版本的 man find 显示的结果?
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/>> 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 , 里面还是过时的信息,:(
感谢。我看了这个帖子觉得楼主问的问题是有道理的,我也理解不了。楼上为文档的小错误辩解,我还以为我不会阅读了……