![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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. |
|
||||
|
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:
Quote:
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. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|