linux的正则表达式查找 [英] linux find regex
问题描述
我使用了找到
命令的正则表达式有问题。也许这是我不理解转义命令行上。
I'm having trouble using the regex of the find
command. Probably something I don't understand about escaping on the command line.
为什么这些不一样呢?
find -regex '.*[1234567890]'
find -regex '.*[[:digit:]]'
猛砸,Ubuntu的
Bash, Ubuntu
推荐答案
与字符类(如 [:数字:]]
)正常前pressions是由使用默认的常规前pression语法找到
不支持。你需要指定不同的正则表达式类型,如 POSIX扩展
,以便使用它们。
Regular expressions with character classes (e.g. [[:digit:]]
) are not supported in the default regular expression syntax used by find
. You need to specify a different regex type such as posix-extended
in order to use them.
看看GNU查找在例行防爆pression <一个href=\"http://www.gnu.org/software/findutils/manual/html_mono/find.html#Regular-Ex$p$pssions\">documentation它会显示所有的正则表达式类型和它们所支持的东西。
Take a look at GNU Find's Regular Expression documentation which shows you all the regex types and what they support.
这篇关于linux的正则表达式查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!