How to swap columns in such a file?
It can be done with awk
using "
as the field separator. But doing that, you must remember that $1
is empty, $2
holds the first string, $3
is the space between strings, $4
is the second string, etc. Also, it's more reliable to swap the two strings instead of just printing all the fields and hoping you put enough $n
s. Bearing these in mind, the following should work:
awk 'BEGIN{OFS=FS="\""} {tmp=$4;$4=$6;$6=tmp;print}' input_file >output_file