how to search for a string within last 15 records


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to search for a string within last 15 records
# 1  
Old 07-18-2012
how to search for a string within last 15 records

Hi,

I have a oracle log file through which I search for a string "ORA-' and if it is present, the job will fail. IF grep('ORA-' $LOGFILE) is used to determine whether the job should fail or not. Log file is populated with help of a sql script

Once the job failed few weeks back to connectivity error. Since grep scans the whole log file, every week the job is failing eventhough script has ran fine.

Is there a way to run grep or find command within last 15 lines of the log file ?

Regards,

Krishna
# 2  
Old 07-18-2012
You could use tail to pipe the last 15 lines of the file into grep.

Regards and welcome to the forum,
Alister
# 3  
Old 07-19-2012
Thanks Alister

It worked like charm, thank you alister.

Regards,

Krishna

---------- Post updated 07-19-12 at 01:13 AM ---------- Previous update was 07-18-12 at 10:03 AM ----------

Last edited by krishnadevanur; 07-19-2012 at 03:16 AM.. Reason: issue solved
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to use a grep search to search for a specific string within multiple directories?

Lets say I have a massive directory which is filled with other directories all filled with different c++ scripts and I want a listing of all the scripts that contain the string: "this string". Is there a way to use a grep search for that? I tried: grep -lr "this string" * but I do not... (3 Replies)
Discussion started by: Circuits
3 Replies

2. UNIX for Beginners Questions & Answers

Search a string and display its location on the entire string and make a text file

I want to search a small string in a large string and find the locations of the string. For this I used grep "string" -ob <file name where the large string is stored>. Now this gives me the locations of that string. Now how do I store these locations in a text file. Please use CODE tags as... (7 Replies)
Discussion started by: ANKIT ROY
7 Replies

3. Shell Programming and Scripting

Search string within a file and list common words from the line having the search string

Hi, Need your help for this scripting issue I have. I am not really good at this, so seeking your help. I have a file looking similar to this: Hello, i am human and name=ABCD. How are you? Hello, i am human and name=PQRS. I am good. Hello, i am human and name=ABCD. Good bye. Hello, i... (12 Replies)
Discussion started by: royzlife
12 Replies

4. Shell Programming and Scripting

Search one string and then search another string in the next line

I am unable to use grep comman to Print only EmpPosition and if the EmpID next line. So output should be both EmpPosition and EmpID and also EmpPosition and EmpID data should match. Sample Data EmpPosition "New" EmpID "New" - - EmpPosition "New" ... (4 Replies)
Discussion started by: onesuri
4 Replies

5. Shell Programming and Scripting

Search several string and convert into a single line for each search string using awk command AIX?.

I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios. Cat test Nov 10, 2012 5:17:53 AM INFO: Request Type Line 1.... (5 Replies)
Discussion started by: laknar
5 Replies

6. Shell Programming and Scripting

Display records between two search strings using sed

I have input file like AAA AAA CCC CCC CCC EEE EEE EEE EEE FFF FFF GGG GGG i was trying to retrieve data between two strings using sed. sed -n /CCC/,/FFF/p input_file Am getting output like CCC CCC CCC (1 Reply)
Discussion started by: NareshN
1 Replies

7. Shell Programming and Scripting

Bash Scripting Search For Records

Hi, I urgently need help with an assignment I must complete by tomorrow. I started Bash Scripting yesterday so am a complete newbie. I don't have time to teach myself Bash scripting so please don't redirect me to some tutorials. The assignment I have to do involves the following: the aim... (1 Reply)
Discussion started by: isxrc
1 Replies

8. Shell Programming and Scripting

Using awk to search variable length records

New to awk and need some help. I have a script that I would like to make more compact. I want to read a file and grab every field, from every record, except the last field. The records are variable length and have varying number of fields. A record will have at least two fields, but can have... (9 Replies)
Discussion started by: synergy_texas
9 Replies

9. Shell Programming and Scripting

Perl: Search for string on line then search and replace text

Hi All, I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text. An example of 4 lines in my file is: 1. MatchText_randomNumberOfText moreData ReplaceMe moreData 2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies

10. UNIX for Dummies Questions & Answers

Select records based on search criteria on first column

Hi All, I need to select only those records having a non zero record in the first column of a comma delimited file. Suppose my input file is having data like: "0","01/08/2005 07:11:15",1,1,"Created",,"01/08/2005" "0","01/08/2005 07:12:40",1,1,"Created",,"01/08/2005"... (2 Replies)
Discussion started by: shashi_kiran_v
2 Replies
Login or Register to Ask a Question