Re: Semi-OT: awk

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



On Fri, Apr 29, 2016 at 10:31:51AM -0400, m.roth@xxxxxxxxx wrote:
> 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];
>         }
>      }
>    }
> }
> 

Note the last sentence in this paragraph from the gawk manpage:

   The in construct may also be used in a for loop to iterate over
   all the elements of an array.  However, the (i, j) in array
   construct only works in tests, not in for loops.

jl
-- 
Jon H. LaBadie                 jon@xxxxxxxxxx
 11226 South Shore Rd.          (703) 787-0688 (H)
 Reston, VA  20190              (703) 935-6720 (C)
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://lists.centos.org/mailman/listinfo/centos



[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux