Searching for a pattern and extracting records related to that pattern


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Searching for a pattern and extracting records related to that pattern
Prev   Next
# 1  
Old 04-01-2013
Searching for a pattern and extracting records related to that pattern

Hi there,


Looking forward to your advice for the below:

I have a file which contains 2 paragraphs related to a particular pattern. I have to search for those paragraphs from a log file and then print a particular line from those paragraphs.

Sample:

I have one file with the fixed patterns

Code:
CCRC_28778426
CCRC_1364658755732
CCRC_1364658755738
CCRC_1364658755917
CCRC_1364658755941
CCRC_1364658756068
CCRC_1364658756084
CCRC_1364658756086
CCRC_1364658756228
CCRC_1364658756472

Using the fix patterns, I have to search for 2 paragraphs related to that pattern. Once that is found, then I have to print the timestamp when those requests came.
Code:
2013-03-31 14:12:59.100805 < APP > (thr:1) [main] com.comptel.eventlink.node.AdapterNodeSingleton processInputRecord
FINE: Processing input record.
2013-03-31 14:12:59.101085 < APP > (thr:1) [main] com.comptel.mc.node.eaibln.NodeApplication process
FINE: Incoming request from: XMLMQ inputType:  inputLink: OUTRECORD
F __JMS_MESSAGE_ID__ ID:414d51204545534f3933315020202020513dbaaa2d289d91
F __RESEND_COUNT__ 0
B OCGWRequest
B Header
F RqId CCRC_28778426
F RqMode 1
F TrySequence 1
F AppId 012
F GatewayAppId 011
F Bulk no
F RqTimeStamp 2013-03-31T14:12:59
F Version 1.0.2
.
B Body
B Request
F SubRqId 1
F FunctionId 2
F ServiceId 119
F SubscriberId 966569297575
F MainAccAmount 9641
F RefillProfileId 8

Code:
2013-03-31 14:12:59.204187 < APP > (thr:1) [main] com.comptel.mc.node.eaibln.xmlmqResponse writeCdrFile
INFO: Error response for MSGID: ID:414d51204545534f3933315020202020513dbaaa2d289d91, RqID:CCRC_28778426 {responseCode=1, RqTim
eStamp=2013-03-31T14:12:59, GatewayAppId=011, RefillProfileId=8, FunctionId=2, RqMode=1, RollBackPossible=TRUE, Bulk=no, respo
nseFrom=UCIP, RollBackBy=CREDIT, MainAccAmount=9641, SubscriberId=966569297575, ApplicationId=012, SubRqId=1, TrySequence=1, r
esponseErrorCode=W220100, OrigRqId=null, responseErrorDescription= ResponseCode 1 - Ok but supervision period exceeded, respon
seStatus=2, responseBackEnd=rc1air5, ServiceId=119, responseTransactionId=195891364728081230}
2013-03-31 14:12:59.204393 < APP > (thr:1) [main] com.comptel.mc.node.eaibln.xmlmqResponse sendResponse
FINE: Outgoing response to XMLMQ_RESPONSE record: RECORD
F __JMS_MESSAGE_ID__ ID:414d51204545534f3933315020202020513dbaaa2d289d91
B OCGWResponse
B Header
F RqId CCRC_28778426
F RqStatus 2
.
B Body
B Response
F SubRqId 1
F TransactionId CCRC_28778426:1
F SubRqStatus 2
F ErrorCode W220100
F ErrorDescription Successful, but supervision period exceeded:  ResponseCode 1 - Ok but supervision period exceeded

Please advise
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

2. UNIX for Dummies Questions & Answers

searching pattern in VI

in my file i have somthing likre kpk_12 kpk_1 kpk_1.tcl kpk_3.tcl kpk kpk kpk i want search only kpk i am using this cmd /kpk ...results it is showing all . any cmd is ther other then this to search exactword in this example kpk it shoulsnot show kpk_* etc Thanks in Advance ... (2 Replies)
Discussion started by: prakumar
2 Replies

3. UNIX for Advanced & Expert Users

Searching and extracting records

Hello, I have a file with DNA sequences and I want to extract some records by searching them with a word in it and then write the whole record into another file. I am new to perl and having trouble to extract the whole record. Instead I am only able to write the line that contains the word. Can... (2 Replies)
Discussion started by: bjorngill
2 Replies

4. UNIX for Dummies Questions & Answers

Pattern searching

Hi, I need small help from you people. In a directory there are around 150 odd files and few them contain the word "TRACK" and few are not. How can I find out the the list of those files which doesn't contain the word "TRACK"? Thanks, Siba (4 Replies)
Discussion started by: siba.s.nayak
4 Replies

5. Shell Programming and Scripting

Searching for a pattern

How do I search for a pattern - N/A in a particular column using awk? (11 Replies)
Discussion started by: rabiu
11 Replies

6. Shell Programming and Scripting

Searching a pattern in file and deleting th ewhole line containing the pattern

Hi All, Please can someone assist in the script I have made that searches a pattern in a file and delete the whole line containing the pattern. #!bin/sh # The pattern that user want to add to the files echo "Enter the pattern of the redirect" read value # check if the user has... (1 Reply)
Discussion started by: Shazin
1 Replies

7. Shell Programming and Scripting

searching for a pattern

can anybode tell me ? I want to search for a pattern present in a whole directory and subdirectories's files containg " crat" I tried grep -r "crat" */* ; is it right ? (3 Replies)
Discussion started by: pranabrana
3 Replies

8. Shell Programming and Scripting

search a pattern and if pattern found insert new pattern at the begining

I am trying to do some thing like this .. In a file , if pattern found insert new pattern at the begining of the line containing the pattern. example: in a file I have this. gtrow0unit1/gctunit_crrownorth_stage5_outnet_feedthru_pin if i find feedthru_pin want to insert !! at the... (7 Replies)
Discussion started by: pitagi
7 Replies

9. Shell Programming and Scripting

Pattern searching pattern in c files

I have a problem in searching a specific pattern in c files. My requirement: I have to find all the division operator in all cfiles. The problem is, the multi line comments and single line comments will also have forward slash in it. Even after avoiding these comments also, if both... (6 Replies)
Discussion started by: murthybptl
6 Replies

10. Programming

pattern searching using C

i think grep can only find char in files matching a pattern without any wildcards like ? correct? It works with * but not ?. how can i write a small c program to find words in a file, like a list, that matches a pattern like ma?y, b??con, etc if grep doesn't understand ? in a pattern search. if... (1 Reply)
Discussion started by: giannicello
1 Replies
Login or Register to Ask a Question