是否可以使用 egrep 来匹配范围内的数字? [英] Is it possible to use egrep to match numbers within a range?

查看:20
本文介绍了是否可以使用 egrep 来匹配范围内的数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在两组数字之间grep/egrep?

Is there a way to grep/egrep between two sets of numbers?

egrep "SomeText [19999-22000]" /some/file.txt

它没有返回值.我期望:

It's not returning the values. I expect:

SomeText 19999 ffuuu  
SomeText 20001 ffuuu  
SomeText 21000 ffuuu  

推荐答案

regex 不是处理数学问题的正确工具(尽管有时它可以),在您的情况下,请尝试 awk:

regex is not the right tool for math stuff (although sometimes it can do), in your case, try the awk:

awk '$2>=19999 && $2<=22000' file

这篇关于是否可以使用 egrep 来匹配范围内的数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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