我知道如何在vi中删除连续的重复内容。要么
或者
输出应该是:
:%!uniq
或者
:g/^\(.*\)$\n\1$/d).
但是我有一个文件,其中的数据是随机排列的,并且有一些重复的行在整个文件中分散出现。如何在不干扰行顺序的情况下删除所有重复项?应该保留第一行独特的行,接下来(或所有其他)的副本应该被删除?
例如:cat file1
Here's looking at you, Kid.
Casablanca
Here's looking at you, Kid.
Go ahead, make my day.
Dirty Harry
sleep 5
Go ahead, make my day.
Yippee-ki-yay
输出应该是:
Here's looking at you, Kid.
Casablanca
Go ahead, make my day.
Dirty Harry
sleep 5
Yippee-ki-yay