Skip to main content
4 of 11
“Then we add one” implied that the addition happened after printing, which is wrong. Reword so that the explanation is correct.
Gilles 'SO- stop being evil'
  • 866.1k
  • 205
  • 1.8k
  • 2.3k

Let's see,

 !a[$0]++ 

first

 a[$0] 

we look at the value of a[$0] (array a with whole input line ($0) as key).

If it does not exist ( ! is negation in test will eval to true)

 !a[$0] 

we print the input line $0 (default action).

Also, we add one ( ++ ) to a[$0], so next time !a[$0] will evaluate to false.

Nice, find!! You should have a look at code golf!

Archemar
  • 32.3k
  • 18
  • 75
  • 107