Search pattern on logfile and search for day/dates and skip duplicate lines if any
Hi,
I've written a script to search for an Oracle ORA- error on a log file, print that line and the .trc file associated with it as well as the dateline of when I assumed the error occured. In most it is the first dateline previous to the error.
Unfortunately, this is not a fool proof script. I assumed that if the ORA- error appears on line n. line n-1 is where the .trc line is and n-2 is the date.
Below is an excerpt of the script.
An excerpt of the $alert_log below is as below. The assumption of the error line, dateline, tracefile line is correct on the first three (3) ORA- errors but not on the fourth one, the one in RED.
Since the 4th one happens immediately after the 3rd one, it should be considered as to have occurred on the same date and can be ignored. To get it to work, if the ORA- error line are consecutive, it should only consider the first one and ignore the others but I don't know how to do this?
In summary, what I am hoping to achieve with the script is:
01 - Search for a specific ORA- errors and print that line, i.e. line n.
02 - Search backward and search for the tracefile/.trc file, that should be the tracefile associated to this error. At the moment I am assuming this is line n-1. How do I search from line n backward and print the line that has the .trc line?
03 - Search backward for the first dateline and that should be the date when this ORA- error occurred. At the moment, I am assuming this is line n-2. How do I search from line n backward and print the first dateline? From the excerpt, the dateline format starts with day of the week, Mon [Month] [Day], Tue [Month] [Day], Wed [Month] [Day] etc.
Guys i need an idea for one logic..in shell scripting am struggling with a logic...So the thing is... i need to search for a word in a huge log file and i need to continue to print few more lines from that line and the consecutive line has to end when it finds the line with date..because i know... (1 Reply)
I have this fileA
TEST FILE ABC
this file contains ABC;
TEST FILE DGHT this file contains DGHT;
TEST FILE 123
this file contains ABC,
this file contains DEF,
this file contains XYZ,
this file contains KLM
;
I want to have a fileZ that has only (begin search pattern for will be... (2 Replies)
Hello,
i have a question.
My problem is that i have a file like:
TEST
JOHN
ADAM
MICHAEL
SEBASTIAN
ANDY
i want find for MICHAEL and want delete lines like this:
TEST (4 Replies)
Hi friends,
I am looking for sed command/script that would search for a given fixed pattern on odd lines and then if it matches, prints the matching pattern and the next line. For example, in the example below, i am looking for pattern 0 and 1011 on odd lines.
########## start of example file... (10 Replies)
I have a file split something like
01/11/2010:
No of users 100
02/11/2010:
No of users 102
03/11/2010:
No of users 99
...
I want to search the file for a particular date and then extract the following line with the date, something like
02/11/2010 No of users 102
I can grep... (6 Replies)
Hi,
I have to search those statements from the file which starts from "shanky"(only shanky, shanky09 or 09shanky is not allowed) and ends with ");". These two string can be in a same line or different line. And also i have to negate those lines which starts with #.
Can any one please give me... (2 Replies)
hi,
I have a file say x.txt containing
xxx
123
bla
bla
...
you
xxx
dfk
dbf
...
me
xxx
...
...
keeps on..
i need to search for pattern in the line starting xxx in the file. If pattern matched, I need to fetch all the lines till i find next xxx. (17 Replies)
I want to search a file for a string and then if the string is found I need the line that the string is on - but also the previous two lines from the file (that the pattern will not be found in)
This is on solaris
Can you help? (2 Replies)