如何使用awk打印最后两列 [英] How to print last two columns using awk
本文介绍了如何使用awk打印最后两列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要打印的是最后两列.
All I want is the last two columns printed.
推荐答案
您可以使用变量NF
,该变量设置为输入记录中字段的总数:
You can make use of variable NF
which is set to the total number of fields in the input record:
awk '{print $(NF-1),"\t",$NF}' file
这假设您至少有2个字段.
this assumes that you have at least 2 fields.
这篇关于如何使用awk打印最后两列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文