Solaris - 具有OR功能的grep [英] Solaris - grep with OR functionality

查看:116
本文介绍了Solaris - 具有OR功能的grep的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Solaris UNIX 的文件中grep 2个模式。


$ b

即grep'pattern1 OR pattern2'文件名。



以下命令

grep'pattern1 \ | pattern2'filename



此命令有什么问题?

注意:我在Solaris上
<您可以使用什么操作系统?



它可以在使用GNU grep的系统上运行,但在BSD,Solaris等, \ | 不受支持。



尝试 egrep 或 grep -E ,例如

  egrep'pattern1 | pattern2'


I want to grep 2 patterns in a file on Solaris UNIX.

That is grep 'pattern1 OR pattern2' filename.

The following command does NOT work:

grep 'pattern1\|pattern2' filename

What is wrong with this command?

NOTE: I am on Solaris

解决方案

What operating system are you on?

It will work with on systems with GNU grep, but on BSD, Solaris, etc., \| is not supported.

Try egrep or grep -E, e.g.

egrep 'pattern1|pattern2'

这篇关于Solaris - 具有OR功能的grep的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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