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

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

Re: gsub w/ field-separator


From: Stepan Kasal
Subject: Re: gsub w/ field-separator
Date: Thu, 14 Aug 2003 21:34:58 +0200
User-agent: Mutt/1.2.5.1i

Hello Richard,
        thank you for your bug report.
The answer is that this behaviour is correct, though.
I'll try to explain.

On Thu, Aug 14, 2003 at 01:08:55PM -0500, Duran, Richard wrote:
>
>    echo "a b:cde:f g" | awk -F : '{gsub(/ /,"",$1);print}' -
>
> produces "ab cde f g" instead of the expected "ab:cde:f g".
> [...]
> replacing the value of the field separator w/ [...] OFS

> But why doesn't
> 
>    echo "a b:cde:f g" | awk -F : '{print}' -
> 
> require that OFS to be assigned a value of ":"?

the answer can be found in the info manual to gawk (type "info gawk")
or in its web version, eg. in
http://www.gnu.org/manual/gawk/html_node/Changing-Fields.html

| When the value of a field is changed (as perceived by awk),
| the text of the input record is recalculated

Until you assign a new value to a field, the record ($0) is not
recalculated and remains the same.  This is why the later example works
without setting OFS to ":".

HTH,
        Stepan Kasal




reply via email to

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