The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl parsing compared to Ksh parsing popeye Shell Programming and Scripting 1 08-06-2008 10:46 PM
Parsing Powerbroker Logs for SysAdmin Changes (SOX) bcouchtx UNIX for Dummies Questions & Answers 1 07-08-2008 02:16 PM
Generating xls with utf-8 format kalyanramurs Shell Programming and Scripting 0 06-21-2008 07:27 AM
Generating a report -Formatted printing -Urgent jisha Shell Programming and Scripting 1 01-10-2008 02:59 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-08-2008
shellscripter shellscripter is offline
Registered User
  
 

Join Date: Oct 2008
Location: chennai
Posts: 16
Question Parsing out the logs and generating report

My file will contain following(log.txt):

start testcase: config loading
......
error XXXX
.....
end testcase: config loading, result failed
start testcase: ping check
.....
error ZZZZZ
.....
error AAAAA
end testcase: Ping check, result failed

I am expecting below output.
=========================================
Testcase: config loading
error XXXX
Testcase: ping check
error ZZZZ
error AAAA
==============================================

There are so many testcases like this in file also the number of error in testcase will vary.

Please give better idea using shell script. Your help will be appreciated.

Thanks
  #2 (permalink)  
Old 10-08-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
Maybe this:
Code:
grep -E "^Testcase:|^error"
  #3 (permalink)  
Old 10-08-2008
shellscripter shellscripter is offline
Registered User
  
 

Join Date: Oct 2008
Location: chennai
Posts: 16
Thanks zaxxon for your response. I have slighty changed my erquirement

start testcase: config loading
......
error XXXX
.....
end testcase: config loading, result failed
start testcase: ping check
.....
error ZZZZZ
.....
error AAAAA
end testcase: Ping check, result failed
start testcase: unconfig
.....
.....
end testcase: unconfig, result passed

I am expecting below output.

Testcase: config loading
error XXXX
error YYYY

Testcase: ping check
error ZZZZ
error AAAA
  #4 (permalink)  
Old 10-08-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Code:
sed -n -e 's%^start testcase: %Testcase:%p' -e '/^error /p' file
  #5 (permalink)  
Old 10-08-2008
shellscripter shellscripter is offline
Registered User
  
 

Join Date: Oct 2008
Location: chennai
Posts: 16
Hi era,

Thanks for your quick response. Please have a look into the modified requirement and let me know ur inputs.
Closed Thread

Bookmarks

Tags
parsing

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:22 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0