Grepping一个巨大的文件(80GB)的方式来加快步伐? [英] Grepping a huge file (80GB) any way to speed it up?
问题描述
grep -i -A 5 -B 5 'db_pd.Clients' eightygigsfile.sql
这已经运行了一个小时它,否则不超载一个相当强大的Linux服务器。
任何其他与grep?关于我的语法可以改善,任何东西(的egrep,fgrep一样好?)
This has been running for an hour on a fairly powerful linux server which is otherwise not overloaded. Any alternative to grep? Anything about my syntax that can be improved, (egrep,fgrep better?)
的文件实际上是在其与安装共享到另一台服务器,但实际磁盘空间的目录是本地所以,不应该有什么区别?
The file is actually in a directory which is shared with a mount to another server but the actual diskspace is local so that shouldn't make any difference?
grep的被抓高达93%的CPU
the grep is grabbing up to 93% CPU
推荐答案
下面是几个选项:
1)preFIX你的grep命令使用C语言环境,而不是UTF-8。
1) Prefix your grep command with LC_ALL=C
to use the C locale instead of UTF-8.
2)使用 fgrep一样
,因为你正在寻找一个固定的字符串,而不是常规的前pression。
2) Use fgrep
because you're searching for a fixed string, not a regular expression.
3)删除 -i
选项,如果你不需要它。
3) Remove the -i
option, if you don't need it.
所以你的命令就变成了:
So your command becomes:
LC_ALL=C fgrep -A 5 -B 5 'db_pd.Clients' eightygigsfile.sql
这也将是更快,如果你复制你的文件到RAM盘。
It will also be faster if you copy your file to RAM disk.
这篇关于Grepping一个巨大的文件(80GB)的方式来加快步伐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!