[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gawk] How to change Field without changing OFS
From: |
Andreas Schwab |
Subject: |
Re: [gawk] How to change Field without changing OFS |
Date: |
Fri, 13 Feb 2009 10:46:46 +0100 |
User-agent: |
Gnus/5.110009 (No Gnus v0.9) Emacs/22.3 (gnu/linux) |
Barco You <address@hidden> writes:
> Hi all,
>
> I'm writing a program like following attached, for processing some file
> including strings like
> "DBTSC:NAME=CCSEXCHANGE,SETNAME=CCSS;"
> ....
> when I change some filed, and then redirect the record to new file, the
> fields will be separated by spaces. like:
> "DBTSC NAME CCSEXCHANGE SETNAME 1"
>
> My problem is: how can I keep the records in original formats with some
> field's value changed.
When awk processes a field assignment it recomputes $0 by concatenating
all fields separated by the current value of OFS. If you want to keep
the original separators you need to split and recombine $0 by hand,
instead of doing a field assignment.
Andreas.
--
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."