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 "|") from the header and the data as well. Can this be done using awk/sed?
Plese NOTE that the data in col3 maybe empty (row 2).
The output should be:
col1|col2|col4
a|b|d
e|f|h
i|j|l
You could simply use cut
.
cut -d'|' -f1-2,4- file
This might work for you (GNU sed):
sed 's/[^|]*|//3' file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With