Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法grep/egrep在两组数字之间?
grep
egrep
egrep "SomeText [19999-22000]" /some/file.txt
它没有返回值。我预计:
SomeText 19999 ffuuu SomeText 20001 ffuuu SomeText 21000 ffuuu
正则表达式不是数学东西的正确工具(尽管有时它可以做到),在你的情况下,试试 awk:
awk '$2>=19999 && $2<=22000' file
您可以使用 range,函数awk
,
awk
awk '$2=="19999",$2=="22000"' file SomeText 19999 ffuuu SomeText 20001 ffuuu SomeText 21000 ffuuu