Date: Mon, 19 Jul 2021 21:25:43 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 257288] awk - loop over array index goes in reverse Message-ID: <bug-257288-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D257288 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=3D226558&action= =3Dedit awk on FreeBSD 12, 13 printed lines in reverse order while iterating over a= rray index While trying to print lines with distinct second field in a line to keep on= ly 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] =3D $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 pri= nted ... 10:09:59 18.1T pool 10:43:46 18.2T pool Attached is the test shell script. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-257288-227>