繁体   English   中英

Linux 命令 GREP - 带空格的精确值

[英]Linux command GREP - Exact value with space

$ cat file.txt | head -n10
icmp_seq=1 ttl=128 time=50.0 ms
icmp_seq=2 ttl=128 time=51.9 ms
icmp_seq=3 ttl=128 time=50.9 ms
icmp_seq=4 ttl=128 time=49.9 ms
$ cat file.txt | grep -v 'time=5 . ms' | head -n 5
icmp_seq=1 ttl=128 time=50.0 ms
icmp_seq=2 ttl=128 time=51.9 ms
icmp_seq=3 ttl=128 time=50.9 ms
icmp_seq=4 ttl=128 time=49.9 ms

我希望它像这样,排除所有带有“time = 5X.XXms”的行:

$ cat file.txt | grep -v "time=5 . ms" | head -n 5
icmp_seq=4 ttl=128 time=49.9 ms

我认为您可以将[0-9]用于X ,这将给出以下正则表达式:

time=5[0-9].[0-9][0-9] ms

所以你得到以下命令:

cat file.txt | grep -v "time=5[0-9].[0-9][0-9] ms" | head -n 5

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM