bug^君 2010-11-16 19:28 采纳率: 25%
浏览 1127
已采纳

使用 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条回答 默认 最新

  • 乱世@小熊 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 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器