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

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

问题描述

我在使用 find 命令的正则表达式时遇到问题.可能是我不明白在命令行上转义的东西.

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:]]'

Bash、Ubuntu

Bash, Ubuntu

推荐答案

使用的默认正则表达式语法不支持具有字符类的正则表达式(例如 [[:digit:]])查找.您需要指定不同的正则表达式类型,例如 posix-extended 才能使用它们.

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 Find 的正则表达式 文档 显示所有正则表达式类型及其支持的内容.

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天全站免登陆