我试过 'find -name .html$' , 'find -name .html\>' .
没有一个工作。

我想知道为什么这两个是错误的,在没有通配符的情况下使用什么是正确的?

请您参考如下方法:

你需要的是

find -name '*.html' 

或者对于正则表达式:
find -regex '.*/.*\.html' 

要忽略大小写,请使用 -iname 或 -iregex:
find -iname '*.html' 
find -iregex '.*/.*\.html' 
-name 手册:
   -name pattern 
          Base of file name (the path with the leading directories 
          removed) matches shell pattern pattern.  The metacharacters 
          (`*', `?', and `[]') match a `.' at the start of the base name 
          (this is a change in findutils-4.2.2; see section STANDARDS CON‐ 
          FORMANCE below).  To ignore a directory and the files under it, 
          use -prune; see an example in the description of -path.  Braces 
          are not recognised as being special, despite the fact that some 
          shells including Bash imbue braces with a special meaning in 
          shell patterns.  The filename matching is performed with the use 
          of the fnmatch(3) library function.   Don't forget to enclose 
          the pattern in quotes in order to protect it from expansion by 
          the shell. 


评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!