我目前正在尝试grep
针对更大的csv文件(3.000.000行)使用大量的ID(〜5000)。
我想要所有包含ID文件中ID的csv行。
我的幼稚方法是:
cat the_ids.txt | while read line
do
cat huge.csv | grep $line >> output_file
done
但这需要永远!
是否有解决此问题的更有效方法?
尝试
grep -f the_ids.txt huge.csv
另外,由于您的模式似乎是固定的字符串,因此提供-F
选项可能会加快速度grep
。
-F, --fixed-strings
Interpret PATTERN as a list of fixed strings, separated by
newlines, any of which is to be matched. (-F is specified by
POSIX.)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句