bug-gawk
[Top][All Lists]
Advanced

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

[bug-gawk] ^. as field separator


From: Oğuz
Subject: [bug-gawk] ^. as field separator
Date: Tue, 16 Apr 2019 18:42:27 +0300

I just came across this behavior in gawk 4.2.1 which I can't find an
explanation for in the POSIX standard, nor in the gawk manual:

$ echo 'foo' | awk 'BEGIN{FS="^.";OFS="|"} {$1=$1} 1'
||o

I expected the output to be `|oo` since `^.` should match the first char on
the line, `f`. I can get that output just be referencing NF before or after
the assignment:

$ echo 'foo' | awk 'BEGIN{FS="^.";OFS="|"} {NF;$1=$1} 1'
|oo

$ echo 'foo' | awk 'BEGIN{FS="^.";OFS="|"} {$1=$1;NF} 1'
|oo

Is this a bug or is that behavior described somewhere in the documentation?


reply via email to

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