我想grep
由regex
但我很难找出我的正则表达式有什么问题。我找不到任何bash正则表达式测试人员,所以这真的很难弄清楚。grep根据正则表达式不匹配任何东西
这里是我的正则表达式
[0-9]*\.[0-9]*[G][:space:]*\.\/[bbg-sevent-test-][0-9]*
我想我的正则表达式匹配这片文字
2.0G ./bbg-sevent-test-132^M
我运行的命令是:
./kafka_prefill.sh | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | grep '[0-9]*\.[0-9]*[G][:space:]*\.\/[bbg-sevent-test-][0-9]*' > data3.txt
这样做是运行我的脚本,翻译/删除我的输出部分,然后grep的基于正则表达式,并把它在文件中data3.txt
我目前正在此错误:
grep: Invalid range end
**更新**感谢埃德宾吉
更新的正则表达式:
^[0-9]*\.[0-9]*[G][[:space:]]*\.\/bbg-sevent-test-[0-9]*$
我的命令不再有正则表达式错误。然而没有什么是匹配的下面是一个示例输出:
********************************************************************************^M
This is a private computer system containing information that is proprietary^M
and confidential to the owner of the system. Only individuals or entities^M
authorized by the owner of the system are allowed to access or use the system.^M
Any unauthorized access or use of the system or information is strictly^M
prohibited.^M
^M
All violators will be prosecuted to the fullest extent permitted by law.^M
********************************************************************************^M
Last login: Tue Dec 29 16:43:23 2015 from 10.81.64.204^M^M
sudo bash^M
cd /data/kafka/tmp/kafka-logs/^M
du -kh . | egrep "bbg-sevent-test-*"^M
-bash: ulimit: open files: cannot modify limit: Operation not permitted^M
### Trinity env = prod ###^M
### Kafka Broker Id = 1 ###^M
### Kafka Broker must be started as root!! ###^M
exit^M
exit^M
### Trinity env = prod ###^M
### Kafka Broker Id = 1 ###^M
### Kafka Broker must be started as root!! ###^M
^[]0;[email protected]:/home/ec2-user^G^[[?1034h[[email protected] ec2-user]# cd /data/kafka/tmp/kafka-logs/^M
^[]0;[email protected]:/data/kafka/tmp/kafka-logs^G[[email protected] kafka-logs]# du -kh . | egrep "bbg-sevent-test-*"^M
2.2G ./bbg-sevent-test-439^M
2.2G ./bbg-sevent-test-638^M
2.2G ./bbg-sevent-test-679^M
2.2G ./bbg-sevent-test-159^M
我只是想这一点
2.2G ./bbg-sevent-test-159
你的'[:space:]'只匹配文字字符':space',你需要'[[:space:]]'。以及埃德下面的表示。祝你们好运。 – shellter