Printing everything except the first field with awk

前端 未结 16 2666
北恋
北恋 2020-12-04 07:04

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         


        
16条回答
  •  生来不讨喜
    2020-12-04 07:43

    awk '{ saved = $1; $1 = ""; print substr($0, 2), saved }'
    

    Setting the first field to "" leaves a single copy of OFS at the start of $0. Assuming that OFS is only a single character (by default, it's a single space), we can remove it with substr($0, 2). Then we append the saved copy of $1.

提交回复
热议问题