在"awk"中打印倒数第二列/字段 [英] Print second-to-last column/field in `awk`
本文介绍了在"awk"中打印倒数第二列/字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 awk
中打印倒数第二列或字段.字段数是 NF
变量.我知道我应该可以使用 $ NF
,但是我不确定如何使用它.
I want to print the second-to-last column or field in awk
. The number of fields is the NF
variable. I know that I should be able to use $NF
, but I'm not sure how it can be used.
这似乎不起作用:
awk ' { print ( $NF-- ) } '
推荐答案
awk '{print $(NF-1)}'
应该工作
这篇关于在"awk"中打印倒数第二列/字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文