我有一個78k行.txt文件,英文單詞和一個5k行.txt文件,最常用的英語單詞。我想整理大列表中最常見的單詞,以便我列出一個不常見的單詞。使用grep查找兩個大型單詞列表之間的差異
我管理解決了我的問題在另一個問題,但我真的想知道,我做錯了,因爲這不起作用。
我曾嘗試以下:
//To make sure they are trimmed
cut -d" " -f1 78kfile.txt | tac | tac > 78kfile.txt
cut -d" " -f1 5kfile.txt | tac | tac > 5kfile.txt
grep -xivf 5kfile.txt 78kfile.txt > cleansed
//But this procedure apparently gives me two empty files.
如果我不切,僅運行grep的第一個,我得到的話,我知道在這兩個文件。
我也試過這樣:
sort 78kfile.txt > 78kfile-sorted.txt
sort 5kfile.txt > 5kfile-sorted.txt
comm -3 78kfile-sorted.txt 5kfile-sorted.txt
//No luck either
兩個文本文件的情況下,有人想嘗試他們的自我: https://www.dropbox.com/s/dw3k8ragnvjcfgc/5k-most-common-sorted.txt https://www.dropbox.com/s/1cvut5z2zp9qnmk/brit-a-z-sorted.txt
請參閱[此StackOverflow問題] [1]的接受答案。 [1]:http://stackoverflow.com/questions/18204904/fast-way-of-finding-lines-in-one-file-that-are-not-in-another –
'切-d「」-f1 78kfile.txt | tac | tac> 78kfile.txt'幾乎肯定會給你'75kfile.txt'的完整副本保存爲'5kfile.txt'。YOu需要將管道的結果保存到一個單獨命名的文件中,也許是'78kfile.tmp'。祝你好運。 – shellter
您可以使用vimdiff查看兩個文件之間的差異。 – Nagaraju