[Bug 257288] awk - loop over array index goes in reverse
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 257288] awk - loop over array index goes in reverse"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 257288] awk - loop over array index goes in reverse"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 257288] awk - loop over array index goes in reverse"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 19 Jul 2021 21:25:43 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257288
Bug ID: 257288
Summary: awk - loop over array index goes in reverse
Product: Base System
Version: 13.0-STABLE
Hardware: Any
OS: Any
Status: New
Severity: Affects Many People
Priority: ---
Component: bin
Assignee: bugs@FreeBSD.org
Reporter: parv.0zero9+freebsd@gmail.com
Created attachment 226558
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=226558&action=edit
awk on FreeBSD 12, 13 printed lines in reverse order while iterating over array
index
While trying to print lines with distinct second field in a line to keep only
the latest lines with 3 fields, the for-loop goes over the array variable in
reverse order surprisingly ...
cat <<_LINE | /usr/bin/awk '{ line[$2] = $0 } END { for ( i in line ) { print
line[i] } }'
10:09:58 18.1T pool
10:09:59 18.1T pool
10:43:45 18.2T pool
10:43:46 18.2T pool
_LINE
10:43:46 18.2T pool
10:09:59 18.1T pool
... I found this behaviour of /usr/bin/awk both on FreeBSD 12.2-RELEASE-p7 &
13-STABLE c 20210628.
OTOH, there was no such unexpected surprise from lang/gawk 5.1.0, which printed
...
10:09:59 18.1T pool
10:43:46 18.2T pool
Attached is the test shell script.
--
You are receiving this mail because:
You are the assignee for the bug.