Is there a way to completely delete fields in awk, so that extra delimiters do not print?

后端 未结 9 1079
醉话见心
醉话见心 2020-12-20 12:52

Consider the following command:

$ gawk -F"\\t" "BEGIN{OFS=\\"\\t\\"}{$2=$3=\\"\\"; p         


        
9条回答
  •  萌比男神i
    2020-12-20 13:14

    The only way I can think to do it in Awk without using a loop is to use gsub on $0 to combine adjacent FS:

    $ echo {1..10} | awk '{$2=$3=""; gsub(FS"+",FS); print}'
    1 4 5 6 7 8 9 10
    

提交回复
热议问题