Here is a "intuitive" answer, for a more in depth explanation of awk's mecanism see either @Isaac's or @Cuonglm's 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). !a[$0] If `a[$0]` wasn't referenced before, it is assigned the empty string. It will evaluate to either "" (empty string) or 0 depending on context. ( `!` is negation in test will evaluate to true) - we print the input line `$0` (default action). - Also, we add one ( `++` ) to `a[$0]`, so next time `!a[$0]` will evaluate to false.