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
AWK - printing certain fields when field order changes in data file eric4 Shell Programming and Scripting 3 04-15-2008 03:48 PM
parsing data file picking out certain fields timj123 Shell Programming and Scripting 8 03-05-2008 03:57 PM
Listing out three fields of data damion UNIX for Dummies Questions & Answers 3 11-08-2007 05:32 PM
Remove Data from Fields greengrass UNIX for Dummies Questions & Answers 4 01-15-2007 02:41 PM
Identifying new fields of data davels SUN Solaris 0 01-10-2005 08:06 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-28-2006
Registered User
 

Join Date: Nov 2005
Posts: 27
How to change Raw data to Coloumn data fields

Dear All,

I have some data file.see below.

--------------ALARM CLEARING FROM SubNetwork=ONRM_RootMo,SubNetwork=AXE,ManagedElement=CGSN--------------
Alarm Record ID: 25196304
Event Time: 2006-08-28 13:41:35
Event Type: Processing error alarm
Object of Reference: SubNetwork=ONRM_RootMo,SubNetwork=AXE,ManagedElement=CGSN
Perceived Severity: Cleared
Probable Cause: Threshold Crossed
Specific Problem: nocSupervisedMeasMin

Problem Text:
Measurement type gprsMmSgsnUnsuccessfulAttachRequests has exceeded its threshold.

--------------ALARM END--------------
--------------ALARM CLEARING FROM SubNetwork=ONRM_RootMo,SubNetwork=AXE,ManagedElement=CGSN--------------
Alarm Record ID: 25203271
Event Time: 2006-08-29 08:37:24
Event Type: Processing error alarm
Object of Reference: SubNetwork=ONRM_RootMo,SubNetwork=AXE,ManagedElement=CGSN
Perceived Severity: Cleared
Probable Cause: Threshold Crossed
Specific Problem: nocSupervisedMeasMin

Problem Text:
Measurement type gprsSmSgsnUnsuccessfulActivations has exceeded its threshold.

--------------ALARM END--------------


I want to make it like this.see below.

Alarm Record ID Event Time Event Type --- --- ---
25196304 2006-08-28 13:41:35 Processing error alarm --- ---- ---
25203274 2006-08-29 08:37:24 ---- ---- ---- ---


How i can do it?

Help me.

Regards,
Nayanajith.
Reply With Quote
Forum Sponsor
  #2  
Old 08-28-2006
Registered User
 

Join Date: Jun 2006
Location: Delhi, India
Posts: 88
Awk(gawk) based solution

Here's a crude solution in gnu awk(gawk). You can save the alarms in a file and will have to make a small change.

Quote:
Problem Text:
Measurement type gprsSmSgsnUnsuccessfulActivations has exceeded its threshold.
appears in 2 lines. Remove the new line character after : so that it reads

Quote:
Problem Text:Measurement type gprsSmSgsnUnsuccessfulActivations has exceeded its threshold.
Then try this code :

Code:
awk -F":" 'BEGIN{phead=0}
/ALARM CLEARING/,/ALARM END/{ 
if($0!~"ALARM CLEARING" && $0 !~ "ALARM END")
 {
  if($1!~"Record ID") {data=data"\t"$2; header=header"\t"$1}
  else {data=data$2; header=header$1}
 }
 if($0~/ALARM END/)
   {data=data"\n";
     if(phead==0) print header;phead=1;}
}
END{print data}' filename
Displays the fields as tab separated entries.
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 12:35 AM.


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