filter a file with other file in bash

谁说我不能喝 提交于 2019-12-23 16:09:51

问题


i Have a file with numbers, for example:

$cat file
31038467
32048169
33058564
34088662
35093964
31018168
31138061
31208369
31538163
31798862

and other for example with

$cat file2

31208369
33058564
34088662
31538163
31038467

Then i need other file with lines that are in the first file but not in the second

cat $output
35093964
31018168
31138061
31798862
32048169

My real file has 12'000.0000 of lines.

Then how can i do it?


回答1:


Is

grep -f file2 -v -F -x file1

sufficient?

NOTE1: Please specify in question, if the actual question is that, you need it to be time/memory optimized.

NOTE2: Get rid of any blank lines in file2.



来源:https://stackoverflow.com/questions/18044007/filter-a-file-with-other-file-in-bash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!