迷惑中搜度娘 看看有没有帮助 发现一文章
https://unix.stackexchange.com/questions/67192/find-command-with-regex-quantifier-e-g-1-2
我们的问题是一致的,那么这个 -regex的选项 到底是不是我们平时使用的正则表达式了?
man 帮助文档
-regex pattern
File name matches regular expression pattern. This is a match on the whole path, not a search. For example, to match a file named `./fubar3‘, you can
use the regular expression `.*bar.‘ or `.*b.*3‘, but not `f.*r3‘. The regular expressions understood by find are by default Emacs Regular Expressions,
but this can be changed with the -regextype option.
发现没有说明 只是说有个 -regextype 选项有介绍他采用的模式
-regextype type
Changes the regular expression syntax understood by -regex and -iregex tests which occur later on the command line. Currently-implemented types are
emacs (this is the default), posix-awk, posix-basic, posix-egrep and posix-extended.
重点来了 他默认使用的是 emacs 风格的 非我们常用的 posix-egrep and posix-extended 格式的正则表达式。问题解决 ,
总结 新手在学习过程中第一时间肯定是怀疑自己的命令输入有问题,根本就不会考虑使用不同风格的问题,等自己确定自己的命令输入没有问题了,才会开始查帮助文档。总的来说 官方的文档其实还是挺全的,就是英语不好的同学,查看起来特别花时间。
原文:https://blog.51cto.com/2858259639/2394148