Solved

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

Posted on 2011-02-14
3
363 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

Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

839 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