我在使用正则表达式时遇到问题find
命令。可能我不明白如何在命令行上转义。
为什么这些不一样?
find -regex '.*[1234567890]'
find -regex '.*[[:digit:]]'
bash、Ubuntu
你应该看看-regextype
的论证find
, see manpage http://manpages.ubuntu.com/manpages/maverick/man1/find.1.html:
-regextype type
Changes the regular expression syntax understood by -regex and -iregex
tests which occur later on the command line. Currently-implemented
types are emacs (this is the default), posix-awk, posix-basic,
posix-egrep and posix-extended.
我猜是emacs
类型不支持[[:digit:]]
构造。我尝试过posix-extended
它按预期工作:
find -regextype posix-extended -regex '.*[1234567890]'
find -regextype posix-extended -regex '.*[[:digit:]]'
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)