The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 01-28-2008
brainyoung brainyoung is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 13
Exclamation 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