# Grep multiple patterns

**URL:** <https://community.unix.com/t/grep-multiple-patterns/156237>\
**Category:** Shell Programming and Scripting\
**Created:** [September 23, 2005, 6:56am UTC](https://community.unix.com/t/grep-multiple-patterns/156237 "2005-09-23T06:56:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![malaymaru](https://community.unix.com/letter_avatar/malaymaru/32/6_449c533f586939b6e5f246632a46421f.png) [@malaymaru](https://community.unix.com/u/malaymaru)\
**Post date:** [September 23, 2005, 6:56am UTC](https://community.unix.com/t/grep-multiple-patterns/156237/1 "2005-09-23T06:56:19Z")

</div>

Hi,

Can we grep multiple patterns in UNIX.  
for example:  
cat /x/y/oratab | grep -i "pattern1|pattern2" .... etc

I require the syntax for multiple patterns. | is not working as I explained in example.

Malay

---

<div class="post-metadata">

**Author:** ![shihabvk](https://community.unix.com/letter_avatar/shihabvk/32/6_449c533f586939b6e5f246632a46421f.png) [@shihabvk](https://community.unix.com/u/shihabvk)\
**Post date:** [September 23, 2005, 7:03am UTC](https://community.unix.com/t/grep-multiple-patterns/156237/2 "2005-09-23T07:03:58Z")

</div>

try !!!!  
cat /x/y/oratab | egrep -i "pattern1|pattern2"

Shihab

---

<div class="post-metadata">

**Author:** ![indo1144](https://community.unix.com/user_avatar/community.unix.com/indo1144/32/62_2.png) [@indo1144](https://community.unix.com/u/indo1144)\
**Post date:** [September 23, 2005, 7:38am UTC](https://community.unix.com/t/grep-multiple-patterns/156237/3 "2005-09-23T07:38:54Z")

</div>

Depending on your version of grep, this might also work:

cat /x/y/oratab | grep -i -e pattern1 -e pattern2

---

<div class="post-metadata">

**Author:** ![vino](https://community.unix.com/user_avatar/community.unix.com/vino/32/156_2.png) [@vino](https://community.unix.com/u/vino)\
**Post date:** [September 23, 2005, 7:40am UTC](https://community.unix.com/t/grep-multiple-patterns/156237/4 "2005-09-23T07:40:37Z")

</div>

Why the UUOC ?

Wouldnt this work ?

```nohighlight
grep -i -e pattern1 -e pattern2 /x/y/oratab

```

vino

---

<div class="post-metadata">

**Author:** ![Just\_Ice](https://community.unix.com/user_avatar/community.unix.com/just_ice/32/165_2.png) [@Just\_Ice](https://community.unix.com/u/Just_Ice)\
**Post date:** [September 25, 2005, 1:20am UTC](https://community.unix.com/t/grep-multiple-patterns/156237/5 "2005-09-25T01:20:27Z")

</div>

or ...

```nohighlight
egrep -i "str1|str2" /your/file

```
