I have been trying to remove a row from a file which has the same first three columns as another row - I have tried lots of different combinations of suggestion on this forum but can't get it exactly right.
Because there's always the first ocurrence that equals 0 which does not count, and it has the same index for the array, the second value overlaps the first, so it's always saved the second value of the same pattern, in case there's a second value with the same pattern.
This time the key was paying attention to the index and how awk saves in the array.
There is no test for 0. It is not necessarily the second line with a given value for the 1st three fields that is saved in the array; it is the last line with a given value for the 1st three fields that is saved. If there is one line with 900 , - , and 1000 as the 1st three fields on the line, respectively, a[$1, $2, $3] 's value (or in this case a["900", "-", "1000"] 's value) will be that entire line. If there is more one line with 900 , - , and 1000 as the 1st three fields on the line, respectively, a[$1, $2, $3] 's value will be the last line starting with those three values.
When processing an array with:
for(i in a)
the elements are processed in a random order (not necessarily the order in which they were found in the input file). This is why aia used sort -n to print the output in the same order as the (sorted) input file.