LC_ALL=C fgrep -A 5 -B 5 'findtest' targetfile
27G左右的文件中查找,用时仅需几分钟。
按多个条件满足其一查询:
LC_ALL=C fgrep -A 5 -B 5 -E 'findtesta|findtestb' targetfile
参考资料:
[1] https://stackoverflow.com/questions/13913014/grepping-a-huge-file-80gb-any-way-to-speed-it-up
[2] https://unix.stackexchange.com/questions/37313/how-do-i-grep-for-multiple-patterns-with-pattern-having-a-pipe-character
本文介绍了一种在大型文件中快速使用grep进行搜索的方法,通过设置LC_ALL环境变量并结合正则表达式,可以在27G左右的文件中几分钟内完成搜索。文中还提供了按多个条件查询的示例。
7761

被折叠的 条评论
为什么被折叠?



