在awk中打印其余字段 [英] Print rest of the fields in awk
本文介绍了在awk中打印其余字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我们有此数据文件.
Suppose we have this data file.
john 32 maketing executive
jack 41 chief technical officer
jim 27 developer
dela 33 assistant risk management officer
我想使用awk
john maketing executive
jack chief technical officer
jim developer
dela assistant risk management officer
我知道可以使用for
来完成.
I know it can be done using for
.
awk '{printf $1; for(i=3;i<=NF;i++){printf " %s", $i} printf "\n"}' < file
问题很长,看起来很复杂.
Problem is its long and looks complex.
是否还有其他简短的方法来打印其余字段.
Is there any other short way to print rest of the fields.
推荐答案
将要跳过的字段设置为空白:
Set the field(s) you want to skip to blank:
awk '{$2 = ""; print $0;}' < file_name
这篇关于在awk中打印其余字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文