Fwd: Help with awk script

From: Atif Jung <atifjung(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Fwd: Help with awk script
Date: 2010-04-20 15:49:23
Message-ID: l2sd1c6b9c51004200849kdb2138e4o45c4af9bb6380b40@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

---------- Forwarded message ----------
From: Atif Jung <atifjung(at)gmail(dot)com>
Date: 20 April 2010 16:47
Subject: Re: [NOVICE] Help with awk script
To: steve(at)retsol(dot)co(dot)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(at)retsol(dot)co(dot)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*
> *R**e**TS**o**l **Ltd*
>
> *DDI: 01323 488548*
>
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Glus Xof 2010-04-20 17:53:34 Specific database vars, again...
Previous Message Tom Lane 2010-04-20 15:21:55 Re: PLPerl not installed correctly?