Printing everything except the first field with awk

前端 未结 16 2668
北恋
北恋 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:51

    $1="" leaves a space as Ben Jackson mentioned, so use a for loop:

    awk '{for (i=2; i<=NF; i++) print $i}' filename
    

    So if your string was "one two three", the output will be:

    two
    three

    If you want the result in one row, you could do as follows:

    awk '{for (i=2; i

    This will give you: "two three"

提交回复
热议问题