There is one awk liner very handful for this:
$ awk '!a[$0]++' file
Here's looking at you, Kid.
Casablanca
Go ahead, make my day.
Dirty Harry
sleep 5
Yippee-ki-yay
It keeps track of the lines processed in the array a[]
. Whenever the line comes again, the counter is already positive so that the condition is false and the line is not printed.
If you want to run it in vim
, do:
:%!awk '\!a[$0]++'
^^
you have to escape the ! to be treated properly