为什么grep promt“无效范围结束”? [英] why grep promt "Invalid range end"?

查看:1964
本文介绍了为什么grep promt“无效范围结束”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个档案 a

I have a file a:

$ cat a 
abcd
kaka

使用命令时:

when using the command:

$ grep -e '[a-d]' a
abcd
kaka

效果很好,但为什么这些命令不对?

It works well, but why those command is not right?

$ grep -e '[\x61-\x74]' a 
grep: Invalid range end

$ grep -e '[\u0061-\u0074]' a 
grep: Invalid range end


推荐答案

假设你的 grep 版本支持 PCRE (Perl兼容的正则表达式),你可以试试:

Assuming that your version of grep supports PCRE ("Perl-compatible regular expressions"), you can try:

grep -P '[\x61-\x74]' a

这会返回预期的输出:

This would return the expected output:

abcd
kaka

这篇关于为什么grep promt“无效范围结束”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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