Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

747 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

11 Experts available now in Live!

Get 1:1 Help Now