linux的正则表达式查找 [英] linux find regex

查看:140
本文介绍了linux的正则表达式查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了找到命令的正则表达式有问题。也许这是我不理解转义命令行上。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆