On 1/14/2008 5:17 PM, Prateek wrote:
> Hi,
> I have a record:
>
> 10276386,12/08/07 00:13:27,12/13/07 00:07:58,Closed,AUTO
> EVENT,"CENTRAL TWS_JOB_ABEND JOB JMKTIS_3TPEMGR00M_LOAD2_FA_FILE
> FAILED, STREAM SMKTIS_TPEMGR01G, NO RECOVERY
> SPECIFIED",P3,F1BCSPSMKTORI
>
> the FS for above is "|"
>
> If i want to output this with "|" replaced by "," along with $6 being
> quoted, I use the following:
> gawk -F\| -v OFS=',' '{gsub(/.*/,"&",$6); print $0>"a"}'
> F1BCSRTECRD.txta
>
> The above works fine as expected.
>
>
> Now if I just try this:
> gawk -F\| -v OFS=',' '{print $0>"a"}' F1BCSRTECRD.txta
> I am not getting an output whose fields are seperated by "," but they
> are instead seperated by existing "|". Can someone please let me know
> why this happens.
In the first script you're altering a field and so forcing a recompilation
of
$0. That's not true in the second script so $0 is untouched. You could do
"$1=$1" to just force the FS to OFS change to occur.
Ed.


|