[CentOS] Semi-OT: awk

m.roth at 5-cent.us m.roth at 5-cent.us
Fri Apr 29 14:31:51 UTC 2016


This is odd, and annoying. CentOS 6, current. Here's my awk script:

{
   room = substr($0, 48, 10);
   arr[$2,room,$1] = $0;
}
END {
  for ( i in arr ) {
     for ( j in arr[i] ) {
        for ( k in arr[i][j] ) {
            print arr[i][j][k];
        }
     }
   }
}

And when I run it, it complains
 awk -f awksort proplist7
awk: awksort:7:      for ( j in arr[i] ) {
awk: awksort:7:                    ^ syntax error
awk: awksort:8:         for ( k in arr[i,j] ) {
awk: awksort:8:                       ^ syntax error
awk: awksort:9:             print arr[i][j][k];
awk: awksort:9:                         ^ syntax error

which makes no sense - I've done this a million times. Am I missing
something, or is this a bug?

     mark




More information about the CentOS mailing list