awk to re-summarize:
Read the http://blog.chinaunix.net/uid-2598756-id-293231.html article and conclude that awk is going to weigh
File1
AAA 111
BBB 222
CCC 333
DDD 444
AAA 111
BBB 222
Method One:
awk ' ++a[$0]==1{print $} ' file1 or awk ' {if (++a[$0]==1) print $} ' file1
Explain the above method:
If Awk is involved in judgment, you can write the judgment outside of the action, write it out without if, write the conditions to judge directly, then the array interpretation, we all know if a text string is the first occurrence, then his value is 0, so AAA 111 This string at the first occurrence of the a[$0] result is 0, and then the result + + operation, the result becomes 1, thus output. If the second occurrence, the result of a[$0] is 1, after the + + operation, the result is not 1, so do not output. The duplicate items are removed.
Method Two:
awk '!a[$0]++{print $} ' file1
Explanatory notes:
This is also the classic way to go heavy, if the first time, a[$0] results for the result of 0,! is 1, in the operation + + operations A[$0] The result is changed to 1, thus the output. But if not for the first time, the result of a[$0] is not 1, the reverse is the result of 0,0++ or 0, so it will not be output.