1 标准的正则表示式 格式 . 表示任意单个字符 * 表示任意次数 + 表示1次或1次以上 {3} 表示精确匹配次数为3次 {n,m}表示n次到m 次之间 ^ 行首锚定 $行尾锚定 < 单词首部锚定 > 单词尾部锚定
2 扩展的正则表达式 相对标准的正则表达式 在次数表示的方面只是少了\ 其他都一样 那么问题来了 find -regex 此时的regex 是使用的正则表达式 此时用到+ 没有使用+ 表示他是使用的扩展的正则表达式, 在实验环境中 所有的文件为 issue issue1 s1 scripts/ ssss find -regex ".s{1,}" 的命令既然无法匹配 到ssss 此文件 find -regex "."s+ 命令却可以匹配

 迷惑中搜度娘 看看有没有帮助 发现一文章
 ![](https://s1.51cto.com/images/blog/201905/14/e3c4b55dc80efad0e8a43f057eaa1887.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
 
 我们的问题是一致的,那么这个 -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 格式的正则表达式。问题解决 , 总结 新手在学习过程中第一时间肯定是怀疑自己的命令输入有问题,根本就不会考虑使用不同风格的问题,等自己确定自己的命令输入没有问题了,才会开始查帮助文档。总的来说 官方的文档其实还是挺全的,就是英语不好的同学,查看起来特别花时间。