searching using grep command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting searching using grep command
# 1  
Old 12-15-2008
searching using grep command

Hi,

i have a file called alert_pindb.log i need to grep and count for all the lines starting with "ORA-" but i need to exclude the line which is having "ORA-00600
"

i am using following syntax to count the ORA- nos

"grep \"ORA-\" alert_pindb.log | wc -l";

since ORA- may be anything like ORA-00000...99999

i need all ORA- errors but i do not want ORA-00600 here i need to exclude ORA-00600 ;

how i can change the above syntax to get count of all ora errors excluding ORA-00600

Thanks

Prakash
# 2  
Old 12-15-2008
A simple solution would be to pipe your first grep results to another grep command like this..
Code:
grep ORA- alert_pindb.log | grep -v "ORA-00600" |wc -l

Hope that helps.
# 3  
Old 12-15-2008
thx for your suggestion

Thanks

Prakash
# 4  
Old 12-15-2008
hi,

the above command which u suggested is giving count of 608 lines which this file is having:
grep ORA- alert_pindb.log | grep -v "ORA-00600" |wc -l

since in this file as of now ora-00600 lines are 0

my requirements is

count(wc-l) should not be the number of lines present in alert log file i want if any error loged in this file apart from ora-00600 it should show a count > 0

because i have perl script which shoot me message if it found count is > 0 and i want this script should shoot me message if it found ora errors apart from ORA-00600

Thanks

Prakash
# 5  
Old 12-15-2008
hi,

i think this will works.
grep -v ORA-00600 alert_pindb.log | grep ORA- alert_pindb.log |wc -l

thanks

prakash
# 6  
Old 12-15-2008
The above suggested command will search for the string ORA- excluding instances of "ORA-00600" and will count the total matched lines. Or you could ommit the "wc -l" command and used the "-c" switch of grep instead. So what is the problem?
Code:
count(wc-l) should not be the number of lines present in alert log file i want if any error loged in this file apart from ora-00600 it should show a count > 0

It is possible that your count will be equal to the number of lines of your log file IF all the lines contains the string "ORA-"..

Can you please elaborate? I am a bit confused with your last post.
# 7  
Old 12-15-2008
Quote:
Originally Posted by prakash.gr
hi,

i think this will works.
grep -v ORA-00600 alert_pindb.log | grep ORA- alert_pindb.log |wc -l

thanks

prakash
this will give you erroneous output. you will be counting all instances of ORA- including ORA-00600. try appending a line with ORA-00600 in your logfile and run this command.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Searching for exact match using grep

I am searching for an exact match on a value read from another file to lookup an email address in another file. The file being checked is called "contacts" and it has Act #, email address, and contact person. 1693;abc1693@yahoo.comt;Tommy D 6423;abc6423@yahoo.comt;Jim Doran... (2 Replies)
Discussion started by: ziggy6
2 Replies

2. Shell Programming and Scripting

Searching for multiple patters using grep

i have a file as below grepfile.txt ---------------- RNTO command successful No such file or directory Authentication failed if i seach individually for 'RNTO command successful' or 'No such file or directory' using grep -i as below, im gettting result. grep -i 'No such file or... (5 Replies)
Discussion started by: JSKOBS
5 Replies

3. UNIX for Dummies Questions & Answers

Grep - Searching for multiple items using one command

I am performing a regular check on UNIX servers which involves logging onto UNIX servers and using the grep command to check if a GID exists in the /etc/group directory e.g. grep 12345 /etc/group I have five to check on each server, is there anyway I can incorporate them into one command and... (2 Replies)
Discussion started by: @MeDaveT
2 Replies

4. Shell Programming and Scripting

dynamic string searching for grep

hi my code is something like count=0 echo "oracle TABLESPACE NAME nd TARGET" while do count=`expr $count + 1` (1) tts_space_name$count=`echo $tts | cut -d "," -f$count` (2) target$count=grep $(tts_space_name$count)... (2 Replies)
Discussion started by: Gl@)!aTor
2 Replies

5. Shell Programming and Scripting

grep searching interval

Hi all, I just want to find all values that are in a specified interval. I tryed it with grep e- file , it does not work. Is it possible to get values wich are lower a special number, like grep >e-18 file? Thanks a lot (4 Replies)
Discussion started by: newcommer
4 Replies

6. Shell Programming and Scripting

grep searching

I am making a script but having little problem. at one part I need to find one number format or other format from a file.. those formats are xxx-xx-xxxx or xxxxxxxxx i tried grep '( \{3\}-\{2\}-\{3\} |\{9\})' if i do them sepratly it work but like this it is not working Please check... (7 Replies)
Discussion started by: Learnerabc
7 Replies

7. Shell Programming and Scripting

can anyone help with shell script command about searching word with grep command?

i want to search in the current directory all the files that contain one word for example "hello" i want to achieve it with the grep command but not with the grep * (2 Replies)
Discussion started by: aintour
2 Replies

8. UNIX for Dummies Questions & Answers

Searching mutiple word - Tuning grep command

Hi all, I have a log file which is more than 1GB, i need to take count from the log file for two strings. i am using the below command but it take a long time to excetue, i need to tune this. Please help me cat /logs/gcbs/gcbsTrace.log | grep -i "ViewStatementBusinessLogic" | grep -c -i... (8 Replies)
Discussion started by: senthilkumar_ak
8 Replies

9. Shell Programming and Scripting

GREP Searching for a newbie...

Hi, I really need some help with GREP searching... I need to find all occurances of a file reference and remove two characters from the end of the reference. For example, here are a few lines showing the text: <image file="STRAIGHT_004CR.jpg" ALT="STRAIGHT_004CR.jpg" /> <image... (8 Replies)
Discussion started by: steveglevin
8 Replies

10. Shell Programming and Scripting

grep - searching for a specific string

ppl, this is my "file" with fields orderno orderdate orderdesc telno street city 1 01/04/2006 abc 123 100 tampa 2 01/04/2006 abc 123 100 tampa 3 01/04/2006 abc 123 100 tampa 4 01/04/2006 abc ... (2 Replies)
Discussion started by: manthasirisha
2 Replies
Login or Register to Ask a Question