I have a csv file with lines like this:
300001;Company Name;023-1 2 3 4 5 6 7;023-3 2 4 6 43 4;[email protected];;;;Street Name;184;;Postal Code;City
I want to strip the spaces from column 3 and 4 (phone and fax number)so that it looks like this:
300001;Company Name;023-1234567;023-3246434;[email protected];;;;Street Name;184;;Postal Code;City
I tried these awk-codes (for column 3) I found on Stackoverflow with no luck:
awk -v FS=OFS=";" '{gsub(/ /,"",$3)} 1' file.csv > test.csv
awk -F, '$3 ~ / / { OFS= ";"; $3 = ""; } 1' file.csv > test.csv
I've been googling for half a day now, but can't find anything that works.
-v FS=OFS=";"expression, thegsub()part is fine. You cannot set two variables in the same expression, so you needed-v FS=";" -v OFS=";".