Is it possible to use egrep to match numbers within a range?

前端 未结 2 846
北荒
北荒 2021-01-16 19:17

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

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

It\'s n

相关标签:
2条回答
  • 2021-01-16 19:59

    You can use the range function , with awk

    awk '$2=="19999",$2=="22000"' file
    SomeText 19999 ffuuu
    SomeText 20001 ffuuu
    SomeText 21000 ffuuu
    
    0 讨论(0)
  • 2021-01-16 20:00

    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
    
    0 讨论(0)
提交回复
热议问题