I have a text file with a sample record that looks like this...
Tampa,Orlando,"Jacksonville,FL",Miami,"Tallahassee,FL"
I need to replace the embedded commas in position 3 and 5 with a space " "
Here is the awk code I have in a bash script...
AWK_script="BEGIN {
OFS=\",\"
}
{
for (i=1; i<=NF; i++)
{
if ( \$i==3 || \$i==5 )
{
gsub(\",\",\" \",\$i)
}
}
print \$0
}
"
echo 'Tampa,Orlando,"Jacksonville,FL",Miami,"Tallahassee,FL"' | awk -vFPAT='([^,]*)|("[^"]+")' "${AWK_script}"
I'm unable to get the gsub to substitute the embedded commas to a space " ". Any help would be greatly appreciated.