必承其重 | 欲带皇冠 2010-11-16 19:28 采纳率: 0%
浏览 456
已采纳

使用 awk 打印除第一个字段以外的所有内容

I have a file that looks like this:

AE  United Arab Emirates
AG  Antigua & Barbuda
AN  Netherlands Antilles
AS  American Samoa
BA  Bosnia and Herzegovina
BF  Burkina Faso
BN  Brunei Darussalam

And I 'd like to invert the order, printing first everything except $1 and then $1:

United Arab Emirates AE

How can I do the "everything except field 1" trick?

转载于:https://stackoverflow.com/questions/4198138/printing-everything-except-the-first-field-with-awk

  • 写回答

15条回答

  • 7*4 2010-11-16 19:32
    关注

    Assigning $1 works but it will leave a leading space: awk '{first = $1; $1 = ""; print $0, first; }'

    You can also find the number of columns in NF and use that in a loop.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(14条)

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型