好了,所以我想刪除重複的行,但它是比這更復雜一點..與扭曲刪除重複行的GnuWin32
我有一個user.txt文件,命名,例如文件是:
users:[email protected]
users1:[email protected]
現在由於我的系統的人的錯誤都能夠使用相同的電子郵件作爲別人註冊了,所以我想,如果行有相同的電子郵件刪除不止一次,例如問題:
user:display:[email protected]
user2:[email protected]
user3:[email protected]
user4:[email protected]
公告浩W用戶,用戶2,用戶3,用戶4都有相同的電子郵件..以及我想刪除用戶2,用戶3,用戶4但保持用戶..反之亦然(第一個被請求接收)刪除任何其他行包含相同的電子郵件..
所以如果
[email protected] is in 20 lines remove 19
[email protected] is in 555 lines remove 554
等..第四
使用電子郵件作爲'awk'數組中的索引。在處理每一行時,如果電子郵件不在數組中,請打印該行並將其添加到數組中。 – Barmar
查看http://stackoverflow.com/questions/2604088/awk-remove-line-if-field-is-duplicate – Barmar
你能解釋一下你的意思嗎?「第一個被請求接受」?你的標準究竟是選擇哪條線?按字母順序排列第一個用戶名?第一個出現在文件中? – Fred