我试图找出其中有两位数字的行。例如:
test.txt
uuLinuxxx
Linux 2011
2011 Linux RedHat
Linux RedHat
2011
2013 2014
2010
/usr/bin
2
Ubuntu 20 world
期望的OP:Ubuntu 20世界
我在用
sed -n '/[0-9]\{2\}/p' test.txt
但是问题是它正在打印所有具有2个或更多数字的行。
这可能对您有用(GNU sed):
sed -n '/\b[0-9]\{2\}\b/p' file
要么:
sed -nr '/\b[0-9]{2}\b/p' file
要么:
sed -r '\b[0-9]{2}\b/!d' file
要么:
sed '/\<[0-9]\{2\}\>/!d' file
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句