# grep all ORA errors except one ORA error

**URL:** <https://community.unix.com/t/grep-all-ora-errors-except-one-ora-error/276796>\
**Category:** UNIX for Advanced & Expert Users\
**Created:** [November 5, 2010, 1:05pm UTC](https://community.unix.com/t/grep-all-ora-errors-except-one-ora-error/276796 "2010-11-05T13:05:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mansoor8810](https://community.unix.com/letter_avatar/mansoor8810/32/6_449c533f586939b6e5f246632a46421f.png) [@Mansoor8810](https://community.unix.com/u/Mansoor8810)\
**Post date:** [November 5, 2010, 1:05pm UTC](https://community.unix.com/t/grep-all-ora-errors-except-one-ora-error/276796/1 "2010-11-05T13:05:21Z")

</div>

Hi - I am trying to grep all "ORA" errors in a log files.I have to grep all ORA errors except one error for example ORA-01653.How can exclude that error in "grep" command?

In following "grep" command I want to exclude "ORA-01653" error

```nohighlight
grep -i ORA alert.log >>/tmp/ora_errors.txt

```

Thanks in advance.

M

---

<div class="post-metadata">

**Author:** ![ctsgnb](https://community.unix.com/letter_avatar/ctsgnb/32/6_449c533f586939b6e5f246632a46421f.png) [@ctsgnb](https://community.unix.com/u/ctsgnb)\
**Post date:** [November 5, 2010, 1:18pm UTC](https://community.unix.com/t/grep-all-ora-errors-except-one-ora-error/276796/2 "2010-11-05T13:18:50Z")

</div>

```nohighlight
grep -i ORA -v 'ORA-01653' alert.log >>/tmp/ora_errors.txt

```

---

<div class="post-metadata">

**Author:** ![Scott](https://community.unix.com/letter_avatar/scott/32/6_449c533f586939b6e5f246632a46421f.png) [@Scott](https://community.unix.com/u/Scott)\
**Post date:** [November 5, 2010, 3:18pm UTC](https://community.unix.com/t/grep-all-ora-errors-except-one-ora-error/276796/3 "2010-11-05T15:18:40Z")

</div>

-i is for ignoring case. All Oracle errors are in upper case.

```nohighlight
$ sed -n "/ORA-/{/01653/!p;}"

```

---

<div class="post-metadata">

**Author:** ![Mansoor8810](https://community.unix.com/letter_avatar/mansoor8810/32/6_449c533f586939b6e5f246632a46421f.png) [@Mansoor8810](https://community.unix.com/u/Mansoor8810)\
**Post date:** [November 5, 2010, 4:29pm UTC](https://community.unix.com/t/grep-all-ora-errors-except-one-ora-error/276796/4 "2010-11-05T16:29:20Z")

</div>

Thanks for your prompt reply.  
I tried both "grep" and "sed" command and "sed" is working fine.

When I tried "grep" command i got following error.  
$grep -i ORA -v "ORA-01653" alert.log

grep: can't open -v  
grep: can't open ORA-01653

Thanks,  
-M

---

<div class="post-metadata">

**Author:** ![ctsgnb](https://community.unix.com/letter_avatar/ctsgnb/32/6_449c533f586939b6e5f246632a46421f.png) [@ctsgnb](https://community.unix.com/u/ctsgnb)\
**Post date:** [November 5, 2010, 4:46pm UTC](https://community.unix.com/t/grep-all-ora-errors-except-one-ora-error/276796/5 "2010-11-05T16:46:19Z")

</div>

```nohighlight
grep ORA alert.log | grep -v ORA-01653

```

```nohighlight
[ctsgnb@shell ~]$ cat alert.log
blablablablabalbala
ORA-01555 blablablabla
blablablablabalbala
ORA-01653 blablablabla
blablablablabalbala
ORA-01234 blablablabla
ORA-09430215 blablablabla
ORA-01653 blablablabla
blablablablabalbala
blablablablabalbala
blablablablabalbala
ORA-09415 blablablabla
[ctsgnb@shell ~]$ grep ORA alert.log|grep -v ORA-01653
ORA-01555 blablablabla
ORA-01234 blablablabla
ORA-09430215 blablablabla
ORA-09415 blablablabla
[ctsgnb@shell ~]$

```

---

<div class="post-metadata">

**Author:** ![durden\_tyler](https://community.unix.com/user_avatar/community.unix.com/durden_tyler/32/1450_2.png) [@durden\_tyler](https://community.unix.com/u/durden_tyler)\
**Post date:** [November 12, 2010, 12:50pm UTC](https://community.unix.com/t/grep-all-ora-errors-except-one-ora-error/276796/6 "2010-11-12T12:50:28Z")

</div>

Or you could use a Perl regular expression with negative lookahead assertion, as shown below with ctsgnb's test file -

```nohighlight
$
$
$ cat alert.log
blablablablabalbala
ORA-01555 blablablabla
blablablablabalbala
ORA-01653 blablablabla
blablablablabalbala
ORA-01234 blablablabla
ORA-09430215 blablablabla
ORA-01653 blablablabla
blablablablabalbala
blablablablabalbala
blablablablabalbala
ORA-09415 blablablabla
$
$
$ perl -lne '/^ORA-(?!01653)/ && print' alert.log
ORA-01555 blablablabla
ORA-01234 blablablabla
ORA-09430215 blablablabla
ORA-09415 blablablabla
$
$

```

tyler\_durden

---

<div class="post-metadata">

**Author:** ![Scrutinizer](https://community.unix.com/user_avatar/community.unix.com/scrutinizer/32/1216_2.png) [@Scrutinizer](https://community.unix.com/u/Scrutinizer)\
**Post date:** [November 12, 2010, 1:14pm UTC](https://community.unix.com/t/grep-all-ora-errors-except-one-ora-error/276796/7 "2010-11-12T13:14:34Z")

</div>

And to complete the list the inevitable awk 🙂

```nohighlight
awk '/ORA/&&!/-01653/' alert.log

```

and a sed variation:

```nohighlight
sed '/-01653/d;/ORA/!d' alert.log

```

---

<div class="post-metadata">

**Author:** ![prestonatwork](https://community.unix.com/letter_avatar/prestonatwork/32/6_449c533f586939b6e5f246632a46421f.png) [@prestonatwork](https://community.unix.com/u/prestonatwork)\
**Post date:** [November 12, 2010, 1:17pm UTC](https://community.unix.com/t/grep-all-ora-errors-except-one-ora-error/276796/8 "2010-11-12T13:17:57Z")

</div>

```nohighlight
sed '/-01653/d;/ORA/!d' alert.log

```
