用bash中的其他文件过滤文件

Cod*_*der 4 linux bash shell solaris sh

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

$cat file
31038467
32048169
33058564
34088662
35093964
31018168
31138061
31208369
31538163
31798862
Run Code Online (Sandbox Code Playgroud)

和其他例如

$cat file2

31208369
33058564
34088662
31538163
31038467
Run Code Online (Sandbox Code Playgroud)

然后我需要其他文件与第一个文件中的行但不在第二个文件中

cat $output
35093964
31018168
31138061
31798862
32048169
Run Code Online (Sandbox Code Playgroud)

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

那怎么办呢?

ani*_*ane 10

grep -f file2 -v -F -x file1
Run Code Online (Sandbox Code Playgroud)

足够?

注1:请指出问题,如果实际问题是,您需要对时间/内存进行优化.

注意2:摆脱file2中的任何空行.