Awk - formater un fichier
J'ai un fichier constitué de plusieurs paquets de la forme :
Code:
1 2 3 4 5 6 7 8 9
| NE Name: |CAO01
NE Type: |SEP
Event ID: |01-janv
Severity: |Critical
Description: |%s: %s unaccessible
New Description:| -- not available --
Long Text: |LAN communication is lost or the process is not running.
Repair Text: |Check for running process set tion path using the LAN.
Annotation: |none |
Et je cherche à le transposer. Voici ce que j'ai écris avec awk mais je n'ai toujours pas le format escompté. Pouvez vous m'aider :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| awk -F "|" '
BEGIN { i=0
REF[i] = "0000"
}
{if (/^NE Name/ ) {i ++
NEName[i".1"] = $2 }
if (/^NE Type/ ) {NEType[i".2"] = $2 }
if (/^Event ID/ ) {EventID[i".3"] = $2 }
if (/^Severity/ ) {Severity[i".4"] = $2 }
if (/^Description/ ) {Description[i".5"] = $2 }
if (/^New Description/ ) {NewDescription[i".6"] = $2 }
if (/^Long Text/ ) {LongText[i".7"] = $2 }
if (/^Repair Text/ ) {RepairText[i".8"] = $2 }
if (/^Annotation/ ) {Annotation[i".9"] = $2 } }
END {
for (a = 1 ; a <= i ; a++)
{print NEName[a".1"] "|" NEType[a".2"] "|" EventID[a".3"] "|" Severity[a".4"] "|" Description[a".5"] "|" NewDescription[a".6"] "|" LongText[a".7"] "|" RepairText[a".
8"] "|" Annotation[a".9"]}
} ' File > Cool.txt |
Merci