首页 > Linux grep 正则表达 “与”

Linux grep 正则表达 “与”

如何用grep搜索出既含有‘hello’又含有‘world’的行?
扩展正则中似乎只有或,没有与,感觉好奇怪。
例:

grep -E 'hello|world' filename    //查找含有hello或world的行
grep -E 'hello&world' finename    //失败。。

请问正确的正则应该如何书写?(不使用管线)
别的语言环境下有类似的正则么?


那不就是:

grep -E 'hello.*world' filename

不嫌麻烦可以这样:

egrep "(hello.*world)|(world.*hello)"

其实用管道更方便,linux的管道如此强大为什么不用?


我一般傻逼似得用两条grep来做吗grep -i 'hello' filename | grep -i 'world'

【热门文章】
【热门文章】