请问grep的工作方式不同的OSX [英] Does grep work differently on OSX

查看:164
本文介绍了请问grep的工作方式不同的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):

  • 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆