Escaping specific character in awk
Hello there,
I have a bit of dirty delimited file, I mentioned dirty because, the delimiter can also appear in wrong positions. However, one uniqueness of this file is
whenever the delimiter appear inside the double quote, then do not consider as delimiter, if it appear outside double then consider it as delimiter.
contents looks like below
abc;def;ghi;"kl;mn;op" ;qrst;uv;w;xyz;
AWk
inp=$1
nawk -F";" '{ print $1"~"$2"~"$3"~"$4"~"$5"~"$6"~"$7"~"$8; }' $inp >> ${inp}_det.txt
gives me ouptut as
abc ~def~ghi~"kl~mn~op" ~qrst~uv
But expected output is
abc ~def~ghi~"kl;mn;op" ~qrst~uv~w~xyz
I'm kind of stuck how to escape the double quote . I appreciate any pointers.
thanks
|