[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: print keep original format
From: |
lina |
Subject: |
Re: print keep original format |
Date: |
Thu, 26 May 2011 12:16:39 +0800 |
I don't understand it so well.
can you help me with this issue?
On Wed, May 25, 2011 at 10:56 PM, Andreas Schwab <address@hidden> wrote:
> lina <address@hidden> writes:
>
>> if I wanna change $4 to B and print the line out
>>
>> 497 FE HEM A 43 -12.543 18.254 -4.989 1.00 0.00
>>
>>
>> for a short awk script, such as
>>
>>
>> awk '{
>> if($2 == 497)
>> {
>> $5="B"
>> print $0
>> }
>> }' $1
>>
>> but the output the space between them has gone. jt turned out loss the
>> format.
>> 497 FE HEM B 43 -12.543 18.254 -4.989 1.00 0.00
>
> Setting any field causes awk to recompute $0 based on the current value
> of OFS. If you want to avoid that you should operate on $0 directly.
>
> *Note (gawk) Changing Fields::
>
> Andreas.
>
> --
> Andreas Schwab, address@hidden
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
>
--
Best Regards,
lina