获取行子集的最有效方法

Pet*_*mit 5 linux bash

我有两个文件。一个巨大的(200.000+ 行)称为“db”,一个巨大的(15.000+ 行)称为“索引”。

从“索引”中过滤掉包含任何索引(行上的任何位置)的“db”中的行的最快方法是什么?

我能想到的解决方案是

for index in $(cat indices); do
  grep $index db >> selection
done;
Run Code Online (Sandbox Code Playgroud)

但这需要很长时间。

在 bash 和 linux 中有更快的方法吗?

Zso*_*kai 5

fgrep -f indices db 
Run Code Online (Sandbox Code Playgroud)

应该更快。