find . -name '*.html'
Run Code Online (Sandbox Code Playgroud)
您必须将通配符用单引号引起来,以防止 shell 在传递通配符进行查找时将其通配。
你需要的是
find -name '*.html'
Run Code Online (Sandbox Code Playgroud)
或者对于正则表达式:
find -regex '.*/.*\.html'
Run Code Online (Sandbox Code Playgroud)
要忽略大小写,请使用 -iname 或 -iregex:
find -iname '*.html'
find -iregex '.*/.*\.html'
Run Code Online (Sandbox Code Playgroud)
手册-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.
Run Code Online (Sandbox Code Playgroud)