I want to parse a huge log file, here's an example shortcut:
= ==== fspCIV0 / vol / vol0 -sec = sys, rw = fspsanp42.net, root = fspsanp42.net, nosuid ===== fcvCIS01 / vol / ARDW-sec = sys, rw / vol / ARDW-sec = Sys, rw / vol / ardw -sec = sys, rw, nosuid / vol / ardw -sec = sys, rw / vol / ardw -sec = sys, rw = none / vol / lonulixda -sec = sys, rw = fcvsan10 Net: fcvsan11.net, root = fcvsan10.net: fcvsan11.net
This is continuing for some more pages this way ...
having the desired output Should:
vfiler, type, host fspCIV0, / vol / vol0, fspsanp42.net fcvCIS01, / vol / lonulixda, fcvsan10.net fcvCIS01, / vol / Lonulixda, fcvsan11.net
Each line begins with '/ vol / ...', which is of type until now, the vFiler line is always' ==== = 'String starts after I've been able to get information already, but the actual problem begins with the server names that are listed after' rw = or ro = '(and the repeated preceding R' Root = ').
It should ignore every row where rw = or ro =. After no server is listed.
With the same type for each new server, I want to start a new line, if more than one server is listed, they are separated by ':'.
I thought it would be possible to list it with the loop in iOS: ''. But I'm not sure how to write it ...
Can anyone help me? Thanks in advance
I have tried it on:
awk -v RS = "=====" -v OFS = ", '' BEGIN ' Print} VFiler "," type "} NF {print $ 1, $ 2} ''
and a time loop I think this could be the job:
< Pre> while IFS = ':' Read -r host $ 1 - $ #;
But I do not know where the loop is right or where it is inserted.
This script can help you with
Input
axis @ aix: / tmp $ cat file ===== FspCIV0 / vol / vol0 -sec = sys, rw = fspsanp42.net, root = fspsanp42.net, Nosuid ===== fcvCIS01 / vol / ARDW-sec = sys, rw / vol / ardw -sec = sys, rw / vol / ardw -sec = sys, rw, nosuid / vol / ardw -sec = sys, rw / Vol / ardw-sec = sys, rw = none / vol / lonulixda -sec = sys, rw = fcvsan10.net: fcvsan11 net, root = fcvsan10.net: fcvsan11.net
< Strong> script
axis @ aix: / tmp $ cat parse_log ($ 0, / root = [^,] * /) {n = $ (substrate) $ 0, RSTART + 5, RLENGTH-5), N, /: /) for (i = 1; i & Lt; = n; i ++) print vfiler, $ 1, n [i]; }
How to execute?
axis @ aix: / tmp $ awk -vOFS = "," -f parse_log .f file,
output
vFiler, type, host fspCIV0, / vol / vol0, fspsanp42.net fcvCIS01, / vol / lonulixda, fcvsan10.net fcvCIS01, / vol / lonulixda, fcvsan11.net < / Code>
Comments
Post a Comment