请问grep的工作方式不同的OSX [英] Does grep work differently on OSX
问题描述
我想用grep像我从Linux的使用,其所有的神奇功能和所有从正则表达式的权力,......但在Mac OS X上它不工作,我期望的那样。
I am trying to use grep like I am used to from Linux, with all its amazing features and all the power from RegEx,... but on Mac OS X it's not working as I expect.
如果我使用-P(Perl的正则表达式),它给我的用法(--help)输出。
在那里,我们发现在参数列表中的-P参数-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ...
仍然没有工作。
If I use "-P" (Perl Regex) it gives me the "usage" (--help) output. In there we find the "-P" parameter in the list of parameters "-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ"... Still not working.
又如星号或加号。
我想这个<一个href=\"http://wiki.bash-hackers.org/howto/conffile\">http://wiki.bash-hackers.org/howto/conffile
要检查内容不当的配置文件指令使用:
To check a config file for inappropriate content that instruction uses:
if egrep -q -v '^#|^[^ ]*=[^;]*' "$configfile"; then
echo "Config file is unclean, cleaning it..." >&2
# filter the original to a new file
egrep '^#|^[^ ]*=[^;&]*' "$configfile" > "$configfile_secured"
configfile="$configfile_secured"
fi
和它不这样行工作:
DATABASE=some_database; ls -la
我是什么做错了吗?
造成这一切的工作只是正常的Linux机器。
What am I doing wrong? Cause all of this works just fine on Linux machines.
推荐答案
在OS X你有FreeBSD的的grep
默认情况下,在Linux上通常GNU grep的
。
On OS X you have FreeBSD grep
by default, on Linux usually GNU grep
.
以下资源也许可以解释为什么GNU的grep似乎更好,速度更快:
The following resources may explain why GNU grep seems to be better (and faster):
- 为什么GNU grep的速度快(由GNU的grep的原作者)
- 在FreeBSD的维基 BSD的grep
- GNU的grep比苹果的grep 10倍的速度更快
- why GNU grep is fast (by GNU grep's original author)
- BSD grep on the FreeBSD Wiki
- GNU grep is 10x faster than Mac grep
这篇关于请问grep的工作方式不同的OSX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!