Simplest thing to do is convert either the commas within the quotes or between the fields to some other char, e.g. this will convert every "," between fields to a tab char:
$ awk 'BEGIN{FS=OFS="\""} {for (i=1;i<=NF;i+=2) gsub(/[[:space:]]*,[[:space:]]*/,"\t",$i)} 1' file
"abcd, xyz" abcd 012
"xyz, 123, abcd" 123 "abcd, pqr"
Then of course you need to find some char that can't occur in your input so you could choose a control char or SUBSEP or something.
Alternatively this will convert every "a" to "aA" and every separator to "aB" so then you KNOW your separator can't occur in your input:
$ awk 'BEGIN{FS=OFS="\""} {gsub(/a/,"aA"); for (i=1;i<=NF;i+=2) gsub(/[[:space:]]*,[[:space:]]*/,"aB",$i)} 1' file
"aAbcd, xyz"aBaAbcdaB012
"xyz, 123, aAbcd"aB123aB"aAbcd, pqr"
and you can do:
$ awk 'BEGIN{FS=OFS="\""} {gsub(/a/,"aA"); for (i=1;i<=NF;i+=2) gsub(/[[:space:]]*,[[:space:]]*/,"aB",$i)} 1' file |
awk -F'aB' '{gsub(/aA/,"a"); print $0; for (i=1;i<=NF;i++) print "\tField " i " = <" $i ">"}'
"abcd, xyz"aBabcdaB012
Field 1 = <"abcd, xyz">
Field 2 = <abcd>
Field 3 = <012>
"xyz, 123, abcd"aB123aB"abcd, pqr"
Field 1 = <"xyz, 123, abcd">
Field 2 = <123>
Field 3 = <"abcd, pqr">
If you'd like to do it all in one command:
$ awk '
function decomma() {
FS = OFS = "\""
$0 = $0
gsub(/a/,"aA")
for (i=1;i<=NF;i+=2)
gsub(/[[:space:]]*,[[:space:]]*/,"aB",$i)
gsub(/aA/,"a")
FS = "aB"
$0 = $0
}
{
print $0
decomma()
for (i=1;i<=NF;i++)
print "\tField " i " = <" $i ">"
}
' file
"abcd, xyz", abcd, 012
Field 1 = <"abcd, xyz">
Field 2 = <abcd>
Field 3 = <012>
"xyz, 123, abcd", 123, "abcd, pqr"
Field 1 = <"xyz, 123, abcd">
Field 2 = <123>
Field 3 = <"abcd, pqr">