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

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 08-29-2006
Nayanajith Nayanajith is offline
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.
  #2 (permalink)  
Old 08-29-2006
vish_indian vish_indian is offline
Registered User
  
 

Join Date: Jun 2006
Location: Delhi, India
Posts: 92
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.
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 11:50 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