I am trying to remov certain columns from a text file on lines that match a string, but then leave the rest of the lines untouched.
Say I have a file (thousand of lines in reality)
10 12 a
USA John TGCAGG
USA John TGCATG
5 2 b
CAN Tom TGCACG
CAN Tom TGCAAC
....
And I want to create a new file that removes the 2nd column in lines that contain TGCA but leaves all other lines intact. I would like to see:
10 12 a
USA TGCAGG
USA TGCATG
5 2 b
CAN TGCACG
CAN TGCAAC
I can modify which columns print on lines that match using a regexp to start awk or sed, but I cant get the other lines (which are not modified) to print, or to preserve the order of those lines.
Do I need to use an if statement in awk? Tried using next but I dont think I have that right.