The UNIX and Linux Forums  

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
I want to print next 3 lines after pattern matching. naree Shell Programming and Scripting 12 05-21-2009 04:04 AM
Print the line within the search pattern manosubsulo Shell Programming and Scripting 3 10-15-2008 08:11 AM
Print block of lines matching a pattern vanand420 Shell Programming and Scripting 1 09-29-2008 06:09 AM
Search file for pattern and grab some lines before pattern frustrated1 Shell Programming and Scripting 2 12-22-2005 03:41 PM
pattern matching and print with sed nymus7 Shell Programming and Scripting 2 04-14-2005 10:36 AM

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

Join Date: Oct 2007
Posts: 328
print certain pattern from 2 lines

i have 2 lines comming out of a script o/p.below the line.

2008-10-14 05:47:05,551 [Thread-6] INFO - LPBatch: [null, 1-GH32X, null, DC:Tue Oct 14 10:12:37 UTC 2008, null, null, Mon Oct 13 05:00:00 CDT 2008, Mon Oct 13 10:00:00 UTC 2008, Tue Oct 14 04:45:00 CDT 2008, Tue Oct 14 09:45:00 UTC 2008, CC, AMR, 94]

2008-10-14 05:47:05,575 [Thread-6] INFO - Number of Intervals Not Inserted: 1 / 95

--------------------------------------------------------------------------

How to print the below o/p from the above 2 lines:

1-GH32X|CC|AMR|Number of Intervals Not Inserted: 1 / 95

------------------------------------------------------------------------

like wise my final o/p varies depending on the above 2 lines but it has to print in this fashion.plz help me in this
  #2 (permalink)  
Old 10-15-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink How are two lines linked/connected

Are the two lines always consecutive?
Are there only two lines, and always two lines?

It would probably be helpful to see a slightly larger sample file - perhaps maybe three pairs of data records? This makes it easier to write a command to extract appropriate data.
  #3 (permalink)  
Old 10-15-2008
ali560045's Avatar
ali560045 ali560045 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 328
Actually according to my script 3 lines will be outputed whenever a pattern is matched

Pattern line
next immediate 2 lines
--------------------------------------------------------------------------

Also the next 2 immediate line varies with each pattern found

below few examples:

2008-10-14 05:47:05,551 [Thread-6] ERROR - CleanLPDataMessage: Missing Intervals: 1
2008-10-14 05:47:05,551 [Thread-6] INFO - LPBatch: [null, 1-GH32X, null, DC:Tue Oct 14 10:12:37 UTC 2008, null, null, Mon Oct 13 05:00:00 CDT 2008, Mon Oct 13 10:00:00 UTC 2008, Tue Oct 14 04:45:00 CDT 2008, Tue Oct 14 09:45:00 UTC 2008, CC, AMR, 94]
2008-10-14 05:47:05,575 [Thread-6] INFO - Number of Intervals Not Inserted: 1 / 95
*********************************************

2008-10-14 05:50:54,072 [Thread-6] ERROR - CleanLPDataMessage: Missing Intervals: 1
2008-10-14 05:50:54,072 [Thread-6] INFO - LPBatch: [null, 1-150KP1, null, DC:Tue Oct 14 10:16:52 UTC 2008, null, null, Mon Oct 13 04:45:00 CDT 2008, Mon Oct 13 09:45:00 UTC 2008, Tue Oct 14 04:45:00 CDT 2008, Tue Oct 14 09:45:00 UTC 2008, CC, AMR, 95]
2008-10-14 05:50:54,101 [Thread-6] INFO - Number of Intervals Not Inserted: 1 / 96
****************************************************

2008-10-14 05:55:41,604 [Thread-6] ERROR - CleanLPDataMessage: Missing Intervals: 1
2008-10-14 05:55:41,604 [Thread-6] INFO - LPBatch: [null, 1-VWEMR, null, DC:Tue Oct 14 10:22:06 UTC 2008, null, null, Mon Oct 13 04:30:00 CDT 2008, Mon Oct 13 09:30:00 UTC 2008, Tue Oct 14 05:00:00 CDT 2008, Tue Oct 14 10:00:00 UTC 2008, CC, AMR, 97]
2008-10-14 05:55:41,634 [Thread-6] INFO - Number of Intervals Not Inserted: 1 / 98

*********************************************


So i wanted the o/p in the below fashion

1-GH32X|CC|AMR|Number of Intervals Not Inserted: 1 / 95
1-150KP1|CC|AMR|Number of Intervals Not Inserted: 1 / 96
1-VWEMR|CC|AMR|Number of Intervals Not Inserted: 1 / 98
Closed Thread

Bookmarks

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 01:28 AM.


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