用bash中的其他文件过滤文件 [英] filter a file with other file in bash

查看:41
本文介绍了用bash中的其他文件过滤文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带数字的文件,例如:

i Have a file with numbers, for example:

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

和其他例如

$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

我的真实文件有12'000.0000行.

My real file has 12'000.0000 of lines.

那我该怎么办?

推荐答案

grep -f file2 -v -F -x file1

足够?

注意1:请具体说明问题,如果实际的问题是,您需要对其进行时间/内存优化.

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

注意2:消除file2中的任何空白行.

NOTE2: Get rid of any blank lines in file2.

这篇关于用bash中的其他文件过滤文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆