Delete a column from a delimited file in linux

前端 未结 7 1066
星月不相逢
星月不相逢 2020-12-19 02:43

I have a file in the following format:

col1|col2|col3|col4
a|b|c|d
e|f||h
i|j|k|l

I would like to delete col3 (with the delimiter \"|\") fr

7条回答
  •  不知归路
    2020-12-19 03:18

    Another awk solution could be useful if you have many columns

    awk -F'|'  '{$3="";$0=$0;$3=$3}1' FPAT='[^|]+' OFS='|' file
    

提交回复
热议问题