Skip to main content

Timeline for awk can't print array element

Current License: CC BY-SA 3.0

8 events
when toggle format what by license comment
Jun 20, 2013 at 16:42 comment added manatwork I think you got it. A generic advice: when confused, dump your variables' values. For example you can put something like this in your script END{for(i in a)printf"a[ %s ] = %s\n",i,a[i]} to list the indexes and values in array a. As with you current code $0 is already listed in the output just above END, should be clearly visible what to use as array index to get the corresponding values.
Jun 20, 2013 at 16:33 comment added pogibas OK, when we says $3 in a it puts f2 $2 into that position, hence to print it we have to say "print position $3".
Jun 20, 2013 at 16:30 comment added pogibas So we are saying: a[$1] - put in array f2 $1; if f1 $3 is in array (that is f2 $1), then print. But 1) why do we need =$2 ; 2) How do we make f2 $2 encoded as a[$3]?
Jun 20, 2013 at 16:26 vote accept pogibas
Jun 20, 2013 at 16:22 history edited manatwork CC BY-SA 3.0
added 365 characters in body
Jun 20, 2013 at 15:33 comment added pogibas Can you please check updated question as answer doesn't seem to work with my actual data.
Jun 20, 2013 at 15:21 vote accept pogibas
Jun 20, 2013 at 15:47
Jun 20, 2013 at 15:11 history answered manatwork CC BY-SA 3.0