bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: print keep original format


From: Andreas Schwab
Subject: Re: print keep original format
Date: Wed, 25 May 2011 16:56:34 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]