bash – 打印awk中的其余字段

前端之家收集整理的这篇文章主要介绍了bash – 打印awk中的其余字段前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
假设我们有这个数据文件.
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

我知道可以使用.

awk '{printf $1;  for(i=3;i<NF;i++){printf " %s",$i} printf "\n"}' < file

问题是它的长,看起来很复杂.

是否还有其他简单的打印方式来打印其余的字段.

将要跳过的字段设置为空白:
awk '{$2 = ""; print $0;}' < file_name

资料来源:Using awk to print all columns from the nth to the last

猜你在找的Bash相关文章