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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Conditionally joining lines in vi ifermon UNIX for Dummies Questions & Answers 0 06-04-2008 06:43 AM
Joining lines from two files - please help chandra004 Shell Programming and Scripting 25 07-26-2006 11:39 PM
Joining 3 lines at a time Sabari Nath S Shell Programming and Scripting 14 12-20-2005 10:29 PM
Joining multiple lines beilstwh Shell Programming and Scripting 4 03-02-2005 02:51 AM
Joining lines in log file bubba112557 Shell Programming and Scripting 3 05-18-2004 04:10 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-11-2005
Registered User
 

Join Date: Mar 2005
Posts: 41
Joining 2 lines in a file together

Hi guys,

I've got a log file which has entries that look like this:

-------------------------------------------------------------------------------
06/08/04 07:57:57
AMQ9002: Channel program started.

EXPLANATION:
Channel program 'INSCCPQ1.HSMTSPQ1' started.
ACTION:
None.
-------------------------------------------------------------------------------

I need a script which will extract the error code and date and display the results like this:


06/08/04 07:57:57 AMQ9002: Channel program started.


So basically it joins the date and AMQ code lines together and then greps on AMQ. The error code ALWAYS starts with AMQ.

Can anyone offer any suggestions on if that can be done?

Thanks

Gareth
Reply With Quote
Forum Sponsor
  #2  
Old 05-11-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
something to start with:

nawk -f m22.awk logFile

this is m22.awk:
Code:
BEGIN {
  FS=RS=""
}

$1 ~ /^[0-9]/ {
   print $1 " " $2
}
Reply With Quote
  #3  
Old 05-12-2005
Registered User
 

Join Date: Feb 2005
Location: Coimbatore, Tamilnadu, India
Posts: 119
awk '{ if ($1 ~ /^[0-9]/) { Ln=$0;getline;print Ln" "$0 }}' <filename> will do it
Reply With Quote
  #4  
Old 05-12-2005
Registered User
 

Join Date: Mar 2005
Posts: 41
thank you, thank you, this works a treat. I'd buy you a pint if you were local!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0