我有一个类似的文件:
number_of_x 100 # total number of x
number_of_y 2000 # total number of y
total_rate 1.67 # rate
blah1 0.876 # blah1
blah2 10450 # blah2
我想提取与number_of_y
和相关的数字total_rate
,例如,这里的输出是:
2000
1.67
这是我能得到的最接近的:
grep -E 'number_of_y|total_rate' my_file | grep -Eo '[0-9.]*'
也许awk会有所帮助:
grep -E 'number_of_y|total_rate' my_file | awk '{print $2}'
更改$2
要显示的任何列
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句