Fwd: Help with awk script - Mailing list pgsql-novice

From Atif Jung
Subject Fwd: Help with awk script
Date
Msg-id l2sd1c6b9c51004200849kdb2138e4o45c4af9bb6380b40@mail.gmail.com
Whole thread Raw
In response to Help with awk script  (Atif Jung <atifjung@gmail.com>)
List pgsql-novice
---------- Forwarded message ----------
From: Atif Jung <atifjung@gmail.com>
Date: 20 April 2010 16:47
Subject: Re: [NOVICE] Help with awk script
To: steve@retsol.co.uk


I found another way, using the octal values for ' and ".
 
awk 'gsub("\047","\042") {print}'
 
Rgds
 

Atif



On 20 April 2010 16:41, Steve T <steve@retsol.co.uk> wrote:
Try:
a="'N','Y','B'"
echo $a|awk '{gsub("'"'"'","\"",$0);print $0}'

NB the differences between ' and " in the  the gsub command - it effectively starts a quoted sting (with a double quote) then ends the awk script with a single quote then quotes a single quote (ie single quote in double quotes), restarts the script with a single quote and then closes that with a double quote!

There's probably a far easier way using [quote] or escaping the quotes - but the above appears to work.
On Tue, 2010-04-20 at 11:44 +0100, Atif Jung wrote:
Can anyone help with the following:
 
Using awk I need to replace every occurance of single quote with a double quote in the string IN ('x','y','z',......). There can be any number of elements in single quotes in between the brackets.
 
IN ('x','y','z'',...) -> IN ("x","y","z",....)
 
Thanks

Atif



Steve Tucknott
ReTSol Ltd

DDI:         01323 488548



pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: PLPerl not installed correctly?
Next
From: Glus Xof
Date:
Subject: Specific database vars, again...