I need to remove a column from my tabulated CSV file if this column exists.
My CSV file:
GENE REF ALT
AKT A G
AKT G G
Desired output: if column REF exists delete this column
GENE ALT
AKT G
AKT G
I tried to do that:
sed 's/\tREF.[^\t]*//' filename.csv
but it doesn't work.
awk 'NF == 3 { print $1,$3}
file`NF
checks if there are at least 3 fields. You might also wantawk -vOFS="\t" 'NF.....} file
.awk '{ print $1, $NF}' OFS='\t' infile
?