如何从文本文件打印逗号之间的特定值?文件中有几行这种类型:
0.9999899864,0.6666600108,0.00,0.00,0.00,36988,140920,1,150.00,1500.00,1400.00,1300.00,1,0.50,2.00,0.10,1.00,-0.10,1,123.40,1,0.0,8,
我想打印第七个值,它是140920
答案1
一种可能性是将cut
分隔符设置为,
:
$ cut -d',' -f 7 test
140920
(再次假设该文件名为test
)。
答案2
您可以使用awk -F "," '{print $7}'
。
例如,如果内容位于 file 中test
,则
awk -F "," '{print $7}' test