这已经在相当强大的 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) 在 grep 命令前加上 LC_ALL=C 以使用 C 语言环境而不是 UTF-8.
1) Prefix your grep command with LC_ALL=C to use the C locale instead of UTF-8.
2) 使用 fgrep 因为您正在搜索固定字符串,而不是正则表达式.
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.
所以你的命令变成:
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) 有什么方法可以加快速度?
发布评论