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

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

Consider the following command:

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


        
9条回答
  •  猫巷女王i
    2020-12-20 13:19

    In the addition of the answer by Suicidal Steve I'd like to suggest one more solution but using sed instead awk.

    It seems more complicated than usage of cut as it was suggested by Steve. But it was the better solution because sed -i allows editing in-place.

    $ sed -i 's/\(.*,\).*,.*,\(.*\)/\1\2/' FILENAME
    

提交回复
热议问题