在 Linux 中尝试使用 find 命令匹配文件名时忽略大小写
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3770866/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ignore case when trying to match file names using find command in Linux
提问by Captain Claptrap
Right now, all I know to use is:
现在,我只知道使用的是:
find / -name string.*
that is case sensitive and it won't find files named:
这是区分大小写的,它不会找到名为:
1string.x
STRing.x
string1.x
How can I search so that all the above would be returned in the search to a case-insensitive matching?
如何搜索以便在搜索中将上述所有内容返回为不区分大小写的匹配?
采纳答案by DigitalRoss
Or you could use find / | grep -i string
或者你可以使用 find / | grep -i string
回答by llasram
Use the -iname
option instead of -name
.
使用该-iname
选项而不是-name
。
回答by Petesh
Use -iname in find for case insensitive file name matches.
在查找不区分大小写的文件名匹配时使用 -iname。
回答by JustinShoffstall
This works as well, if you want to avoid the single quotes:
如果您想避免使用单引号,这也有效:
find . -iname \*string\*
回答by Inian
If the system you are in does not have the find
command provided by the GNU utils package, you can use the -name
tag alone with POSIX bracket expressions as
如果您所在的系统没有find
GNU utils 包提供的命令,您可以将-name
标记单独与 POSIX 括号表达式一起使用,如
find . -name '*[Ss][Tt][Rr]ing*'