Skip to main content
8 events
when toggle format what by license comment
Jun 25, 2013 at 19:52 comment added jw013 As long as file1 is not huge (for some value of huge), I'd prefer this solution as it doesn't require any sorting of file2 and would be expected to be much more efficient.
Jun 25, 2013 at 19:50 comment added jw013 @Kaz Here's the POSIX quote: "The application shall ensure that a multi-dimensioned index used with the in operator is parenthesized. The in operator, which tests for the existence of a particular array element, shall not cause that element to exist. Any other reference to a nonexistent array element shall automatically create it." It can be found by scrolling a paragraph or two up from here.
Jun 21, 2013 at 13:00 comment added Olivier Dulac @Kaz: awk is a beautiful little tool ^^ I find it easier to read than perl (but of course slower and less powerfull, the latter which makes for the better readability as it has less single-character-special-variables ^^)
Jun 21, 2013 at 7:19 comment added Stéphane Chazelas @Kaz, yes that can be confusing, and you find many scripts not knowingly allocating array elements unintentionally by doing if (a[$1]) instead of if ($1 in a) for instance. It's the case of every awk including the original awk and nawk, but looking at the standard yesterday, I couldn't find it specified.
Jun 20, 2013 at 23:26 comment added Kaz I can't believe that simply evaluating w[$0] has the side effect of adding the key to the array.
Jun 20, 2013 at 23:23 comment added Kaz I would only accept this one. It does not invoke any O(n log n) sorting, and does not fail strangely when the patterns contain regex meta-characters, and could be extended to support regexes.
Jun 20, 2013 at 19:15 history edited Stéphane Chazelas CC BY-SA 3.0
deleted 3 characters in body
Jun 20, 2013 at 19:09 history answered Stéphane Chazelas CC BY-SA 3.0