[Solved] Need Help on Selecting a particular record


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] Need Help on Selecting a particular record
# 1  
Old 11-16-2011
[Solved] Need Help on Selecting a particular record

Hi Guys,

Following is my Input file.

Code:
Time    : Wed Nov 16 02:32:09 2011
Type    : INFO
User    : dsadm
Message :
        Oracle_Connector_2: The connector generated the following TRUNCATE TABLE statement at runtime: TRUNCATE TABLE CANADA_INDUSTRY_OBJECTIVES.
Time    : Wed Nov 16 02:32:09 2011
Type    : INFO
User    : dsadm
Message :
        Oracle_Connector_2: The connector truncated the table CANADA_INDUSTRY_OBJECTIVES.
Time    : Wed Nov 16 02:32:09 2011
Type    : INFO
User    : dsadm
Message :
        Sequential_File_0,0: Import complete; 4 records imported successfully, 0 rejected.
Time    : Wed Nov 16 02:32:09 2011
Type    : WARNING
User    : dsadm
Message :
        Transformer_1,0: Conversion error calling conversion routine decimal_from_string data may have been lost
Time    : Wed Nov 16 02:32:09 2011
Type    : WARNING
User    : dsadm
Message :
        Transformer_1,0: Conversion error calling conversion routine decimal_from_string data may have been lost
Time    : Wed Nov 16 02:32:09 2011
Type    : WARNING
User    : dsadm
Message :
        Transformer_1,1: Conversion error calling conversion routine decimal_from_string data may have been lost
Time    : Wed Nov 16 02:32:09 2011
Type    : WARNING
User    : dsadm
Message :
        Transformer_1,1: Conversion error calling conversion routine decimal_from_string data may have been lost
Time    : Wed Nov 16 02:32:09 2011
Type    : INFO
User    : dsadm
Message :
        Oracle_Connector_2,0: The connector connected to Oracle server GMNGSRDB.
Time    : Wed Nov 16 02:32:10 2011
Type    : INFO
User    : dsadm
Message :
        Oracle_Connector_2,1: The connector connected to Oracle server GMNGSRDB.

Whenever Type is Warning, i need the Message as output.

For Some reason when i ran the grep command as
Quote:
grep -e "Type : WARNING" STG_D_Ind_Obj_CAN_010.log
I am not getting any records. This will be the starting step for me. But if somebody can help me out with getting Messages out for Warning Type. It would be helpful.

cheers!!!!!
# 2  
Old 11-16-2011
For starters, you need
Code:
grep "Type  *:  *WARNING"

If your grep has -A or -B options, you can get the lines After or Before with a count
Code:
grep -A2 "Type  *:  *WARNING"

(I omitted the filename for brevity)
# 3  
Old 11-16-2011
Thanks for that information otheus....

I have found my solution too by using awk and grep Smilie
Quote:
awk '/WARNING/{_=4}_&&_--' STG_D_Ind_Obj_CAN_010.log | grep -v ^[A-Z
---------- Post updated at 02:33 PM ---------- Previous update was at 02:27 PM ----------

Quote:
Originally Posted by otheus
For starters, you need
Code:
grep "Type  *:  *WARNING"

If your grep has -A or -B options, you can get the lines After or Before with a count
Code:
grep -A2 "Type  *:  *WARNING"

(I omitted the filename for brevity)
I tried your solution Otheus,, but it aint working.
Code:
appl/data/Test/daily> grep "WARNING" STG_D_Ind_Obj_CAN_010.log
Type    : WARNING
Type    : WARNING
Type    : WARNING
Type    : WARNING
appl/data/Test/daily> grep "Type  *:  *WARNING" STG_D_Ind_Obj_CAN_010.log
appl/data/Test/daily>

Can you let me know what i am doing wrong.

Cheers!!!
# 4  
Old 11-16-2011
Try this:
Code:
awk '/WARNING/{f=4}--f==0' file

# 5  
Old 11-16-2011
@Franklin52,,,
That was lovely... that is exactly i was looking at...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need code for updating second record to first record in shell scripting

Hi,, I have requirement that i need to get DISTINCT values from a table and if there are two records i need to update it to one record and then need to submit INSERT statements by using the updated value as a parameter. Here is the example follows.. SELECT DISTINCT ID FROM OFFER_GROUP WHERE... (1 Reply)
Discussion started by: Samah
1 Replies

2. Shell Programming and Scripting

Replace a string for every record after the 1st record

I have data coming in the below format for each record <?xml version="1.0" encoding="UTF-8" standalone="no"?><test_sox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><testdetials>....</test_sox> <?xml version="1.0" encoding="UTF-8" standalone="no"?><test_sox... (8 Replies)
Discussion started by: dsravanam
8 Replies

3. Shell Programming and Scripting

Extract timestamp from first record in xml file and it checks if not it will replace first record

I have test.xml <emp><id>101</id><name>AAA</name><date>06/06/14 1811</date></emp> <Join><id>101</id><city>london</city><date>06/06/14 2011</date></join> <Join><id>101</id><city>new york</city><date>06/06/14 1811</date></join> <Join><id>101</id><city>sydney</city><date>06/06/14... (2 Replies)
Discussion started by: vsraju
2 Replies

4. Shell Programming and Scripting

[Solved] awk command to read sequentially from a file until last record

Hello, I have a file that looks like this: Generated geometry (...some special descriptor) 1 0.56784 1.45783 -0.87965 8 1.29873 -0.8767 1.098789 ... ... ... ... Generated geometry (....come special descriptor) ... .... ... ... ... ... ... ... and... (4 Replies)
Discussion started by: jaldo0805
4 Replies

5. Shell Programming and Scripting

How to compare current record,with next and previous record in awk without using array?

Hi! all can any one tell me how to compare current record of column with next and previous record in awk without using array my case is like this input.txt 0 32 1 26 2 27 3 34 4 26 5 25 6 24 9 23 0 32 1 28 2 15 3 26 4 24 (7 Replies)
Discussion started by: Dona Clara
7 Replies

6. Red Hat

[Solved: Missing A Record] DNS issue

Hi, I have recently built a new DNS server and created a new zone. I use an ESMTP server to handle mail and the new domain has been added to this. I can send mail to gmail and other domain addresses but unable to send it to one particular domain. (DSN:Service Unavailable) DNS... (2 Replies)
Discussion started by: Duffs22
2 Replies

7. Shell Programming and Scripting

Reject the record if the record in the next line does not begin with 2.

Hi, I have a input file with the following entries: 1one 2two 3three 1four 2five 3six 1seven 1eight 1nine 2ten 2eleven 2twelve 1thirteen 2fourteen The output should be: (5 Replies)
Discussion started by: supchand
5 Replies

8. Shell Programming and Scripting

Reject the record if the record in the next line does not satisfy the pattern

Hi, I have a input file with the following entries: 1one 2two 3three 1four 2five 3six 1seven 1eight 1nine 2ten The output should be 1one 2two 3three 1four 2five 3six (2 Replies)
Discussion started by: supchand
2 Replies

9. Shell Programming and Scripting

selecting record by matching in two columns values

Hi Guys ! i want to search a record in file by matching two values in a record in two different columns suppose i have 3 columns and i want to select all those values from col1 for which in col3 has a specific value e.g select all "john" from column1 where column 3 has a value of "20" ... (9 Replies)
Discussion started by: ourned
9 Replies

10. UNIX for Dummies Questions & Answers

how to read record by record from a file in unix

Hi guys, i have a big file with the following format.This includes header(H),detail(D) and trailer(T) information in the file.My problem is i have to search for the character "6h" at 14 th and 15 th position in all the records .if it is there i have to write all those records into a... (1 Reply)
Discussion started by: raoscb
1 Replies
Login or Register to Ask a Question