?
Solved

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

Posted on 2011-02-14
3
Medium Priority
?
373 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 1400 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 600 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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.
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

801 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