Need awk/sed command to pull out matching lines from a block


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need awk/sed command to pull out matching lines from a block
# 1  
Old 06-17-2013
Need awk/sed command to pull out matching lines from a block

Hi,

In order to make our debugging easier in log files, I need this script.
My log file will be structured like this :

------Invoking myfile -param:start_time=1371150900000 -param:end_time=1371151800000 for 06/14/2013

<multiple lines here>
.....
- Step Sybase CDR Table.0 ended successfully, processed 10 lines

----------Invoking myfile -param:cmr_table=cmr_table_L_20130614 -param:start_time=1371151800000 -param:end_time=1371152700000 for 06/14/2013


As you see, Invoking line gets added everytime my process is run.
I want to have a script that adds the following lines :
------Invoking myfile -param:start_time=1371150900000 -param:end_time=1371151800000 for 06/14/2013
- Step Sybase CDR Table.0 ended successfully, processed 10 lines
----------Invoking myfile -param:cmr_table=cmr_table_L_20130614 -param:start_time=1371151800000 -param:end_time=1371152700000 for 06/14/2013
- - Step Sybase CDR Table.0 ended successfully, processed 30 lines.

How do I do it ?

Thanks in Advance.
# 2  
Old 06-17-2013
Since you didn't provide much clue :
I assume this coud be a start :
Code:
awk '/Invoking/||/Sybase CDR Table/' yourlogfile

# 3  
Old 06-17-2013
Thanks, That solved my problem.Smilie
# 4  
Old 06-17-2013
Can be shorten some
Code:
awk '/Invoking|Sybase CDR Table/' yourlogfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed/awk command to convert number occurances into date format and club a set of lines

Hi, I have been stuck in this requirement where my file contains the below format. 20150812170500846959990854-25383-8.0.0 "ABC Report" hp96880 "4952" 20150812170501846959990854-25383-8.0.0 End of run 20150812060132846959990854-20495-8.0.0 "XYZ Report" vg76452 "1006962188"... (6 Replies)
Discussion started by: Chinmaya Kabi
6 Replies

2. Shell Programming and Scripting

Replacing lines matching a multi-line pattern (sed/perl/awk)

Dear Unix Forums, I am hoping you can help me with a pattern matching problem. What am I trying to do? I want to replace multiple lines of a text file (that match a multi-line pattern) with a single line of text. These patterns can span several lines and do not always have the same number of... (10 Replies)
Discussion started by: thefang
10 Replies

3. Shell Programming and Scripting

Matching a block of data sed or ksh

I have the need to check content of very many files for a block of text. I know the data should match for instance/as an example the following The list of characters bugs bunny tom and jerry Mighty mouse Felix the cat / In the first step, I isolated the interesting data by... (3 Replies)
Discussion started by: popeye
3 Replies

4. Shell Programming and Scripting

Sed/awk/perl command to replace pattern in multiple lines

Hi I know sed and awk has options to give range of line numbers, but I need to replace pattern in specific lines Something like sed -e '1s,14s,26s/pattern/new pattern/' file name Can somebody help me in this.... I am fine with see/awk/perl Thank you in advance (9 Replies)
Discussion started by: dani777
9 Replies

5. Shell Programming and Scripting

Printing a block of lines from a file, if that block does not contain two patterns using sed

I want to process a file block by block using sed, and if that block does not contain two patterns, then that complete block has to be printed. See below for the example data. ................................server 1............................... running process 1 running... (8 Replies)
Discussion started by: Kesavan
8 Replies

6. Shell Programming and Scripting

sed or awk delete character in the lines before and after the matching line

Sample file: This is line one, this is another line, this is the PRIMARY INDEX line l ; This is another line The command should find the line with “PRIMARY INDEX” and remove the last character from the line preceding it (in this case , comma) and remove the first character from the line... (5 Replies)
Discussion started by: KC_Rules
5 Replies

7. Shell Programming and Scripting

Command to remove duplicate lines with perl,sed,awk

Input: hello hello hello hello monkey donkey hello hello drink dance drink Output should be: hello hello monkey donkey drink dance (9 Replies)
Discussion started by: cola
9 Replies

8. Shell Programming and Scripting

awk/sed search lines in file1 matching columns in file2

Hi All, as you can see I'm pretty new to this board. :D I'm struggling around with small script to search a few fields in another file. Basically I have file1 looking like this: 15:38:28 sz:10001 pr:14.16 15:38:28 sz:10002 pr:18.41 15:38:29 sz:10003 pr:19.28 15:38:30 sz:10004... (1 Reply)
Discussion started by: floripoint
1 Replies

9. Shell Programming and Scripting

awk/sed Command : Parse parameter file / send the lines to the ksh export command

Sorry for the duplicate thread this one is similar to the one in https://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html#post302255121 Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Discussion started by: rajan_san
4 Replies

10. Shell Programming and Scripting

Print block of lines matching a pattern

Hi :), I am using the script to search "MYPATTERN" in MYFILE and print that block of lines containing the pattern starting with HEADER upto FOOTER. But my problem is that at some occurrence my footer is different e.g. ";". How to modify the script so that MYPATTERN between HEADER and different... (1 Reply)
Discussion started by: vanand420
1 Replies
Login or Register to Ask a Question