Solved

How can a condition in a script look for "case sensitive" words ?

Posted on 2011-02-14
3
362 Views
Last Modified: 2013-11-17
I have this condition in order to send me a log if it encounters any of this word.  The thing is I need this "case sensitive', because the log has a filename with the word "Rejected" in it and send me the log as it where an error.

PARAM1=$(egrep -i -c "ORA-|rejected|Killed|skipped|EXP-" "$log")
0
Comment
Question by:LindaC
3 Comments
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 350 total points
ID: 34889513

i think you need to remove option -i from command

PARAM1=$(egrep -c "ORA-|rejected|Killed|skipped|EXP-" "$log")
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 150 total points
ID: 34894799
Yes,

the "-i" flag means "Ignore the case (uppercase or lowercase) of letters when making comparisons", so it should obviously not be used here.

But moreover, egrep supports some kind of regular expressions, so assuming you were searching for "Killed" or "killed" or "rejected" but not "Rejected" you could do:

egrep -c "ORA-|rejected|[kK]illed|skipped|EXP-" "$log"

or assuming you were searching for "ORA-" messages whose numbers start with 1, 2, 3 or 9 you could do:

egrep -c "ORA-[1-3,9]|rejected|[kK]illed|skipped|EXP-" "$log"

A last example: Search for "dropped" or "skipped":

egrep -c "ORA-[1-3,9]|rejected|[kK]illed|(dro|ski)pped|EXP-" "$log"

Have fun!

wmp




0
 
LVL 8

Author Closing Comment

by:LindaC
ID: 34895935
Thank you so much !
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now