AWK - Parse a big file

INPUT SAMPLE

 
Symmetrix ID          : 000192601507
Masking View Name     : TS00P22_13E_1
Last updated at       : 05:10:18 AM on Tue Mar 22,2011
Initiator Group Name  : 10000000c960b9cd
   Host Initiators
     {
       WWN  : 10000000c960b9cd
     }
Port Group Name       : 10000000c960b9cd_13E_1
   Director Identification
     {
       FA-13E:1
     }
Storage Group Name    : 10000000c960b9cd_13E_1
Sym Dev                                 Host
Name    Dir:P  Physical Device Name      Lun  Attr  Cap(MB)
------  -----  -----------------------  ----  ----  -------
0149    13E:1  Not Visible                 1              3
014A    13E:1  Not Visible                 2              3
014B    13E:1  Not Visible                 3              3
014C    13E:1  Not Visible                 4              3
                                                    -------
Total Capacity                                           12
Masking View Name     :TS00P22_4E_1
Last updated at       : 05:10:26 AM on Tue Mar 22,2011
Initiator Group Name  : 10000000c960bc81
   Host Initiators
     {
       WWN  : 10000000c960bc81
     }
Port Group Name       : 10000000c960bc81_4E_1
   Director Identification
     {
       FA-4E:1
     }
Storage Group Name    : 10000000c960bc81_4E_1
Sym Dev                                 Host
Name    Dir:P  Physical Device Name      Lun  Attr  Cap(MB)
------  -----  -----------------------  ----  ----  -------
0149    04E:1  Not Visible                 1              3
014A    04E:1  Not Visible                 2              3
014B    04E:1  Not Visible                 3              3
014C    04E:1  Not Visible                 4              3
                                                    -------
Total Capacity                                           12
 

OUTPUT

Symmetrix ID,DEV,Storage Group Name,Port Group Name,Initiator Group Name,Masking View Name,Port
000192601507,0149,10000000c960b9cd_13E_1,10000000c960b9cd_13E_1,10000000c960b9cd,TS00P22_13E_1,13E:1
000192601507,014A,10000000c960b9cd_13E_1,10000000c960b9cd_13E_1,10000000c960b9cd,TS00P22_13E_1,13E:1
000192601507,014B,10000000c960b9cd_13E_1,10000000c960b9cd_13E_1,10000000c960b9cd,TS00P22_13E_1,13E:1
000192601507,014C,10000000c960b9cd_13E_1,10000000c960b9cd_13E_1,10000000c960b9cd,TS00P22_13E_1,13E:1
000192601507,0149,10000000c960bc81_4E_1,10000000c960bc81_4E_1,10000000c960bc81,TS00P22_4E_1,04E:1
000192601507,014A,10000000c960bc81_4E_1,10000000c960bc81_4E_1,10000000c960bc81,TS00P22_4E_1,04E:1
000192601507,014B,10000000c960bc81_4E_1,10000000c960bc81_4E_1,10000000c960bc81,TS00P22_4E_1,04E:1
000192601507,014C,10000000c960bc81_4E_1,10000000c960bc81_4E_1,10000000c960bc81,TS00P22_4E_1,04E:1

Thanks

awk '
 BEGIN { OFS=",";
    print "Symmetrix ID,DEV,Storage Group Name,Port Group Name,Initiator Group Name,Masking View Name,Port"
    split("SymmetrixID:,StorageGroupName,PortGroupName,InitiatorGroupName,MaskingViewName", T, ","); 
    for(i in T) GRP[T]=i; }
 ($1$2$3 in GRP) { gsub(":", "", $NF); ID[GRP[$1$2$3]]=$NF }
 /^    / {getdev=0}
 getdev { print ID[1],$1,ID[2],ID[3],ID[4],ID[5],$2 }
 /^------/ { getdev=1 }' infile

Thanks for helping out again Chubler .... works fine ... just one problem , my bad ...some of the records are like this

 
Masking View Name     : BC_db00p42_43
Last updated at       : 05:09:54 AM on Tue Oct 19,2010
Initiator Group Name  : 10000000c96145d5 *
   Host Initiators
     {
       WWN  : 10000000c96145d5
     }
Port Group Name       : BL_db00p42_43
   Director Identification
     {
       FA-1G:0
       FA-16G:0
       FA-3H:0
       FA-14H:0
     }
Storage Group Name    : BL_db00p42_43
Sym Dev                                 Host
Name    Dir:P  Physical Device Name      Lun  Attr  Cap(MB)
------  -----  -----------------------  ----  ----  -------
0297    01G:0  Not Visible                 1  (M)    235521
        16G:0  Not Visible                 1  (M)   
        03H:0  Not Visible                 1  (M)   
        14H:0  Not Visible                 1  (M)   
0351    01G:0  Not Visible                 2  (M)    860160
        16G:0  Not Visible                 2  (M)   
        03H:0  Not Visible                 2  (M)   
        14H:0  Not Visible                 2  (M)   
0AD4    01G:0  Not Visible                14  (M)    102403
        16G:0  Not Visible                14  (M)   
        03H:0  Not Visible                17  (M)   
        14H:0  Not Visible                17  (M)   
0B31    01G:0  Not Visible                 3  (M)    706562
        16G:0  Not Visible                 3  (M)   
        03H:0  Not Visible                 3  (M)   
        14H:0  Not Visible                 3  (M)   
0B37    01G:0  Not Visible                 4  (M)    706562
        16G:0  Not Visible                 4  (M)   
        03H:0  Not Visible                 4  (M)   
        14H:0  Not Visible                 4  (M)   
0BB8    01G:0  Not Visible                 9  (M)    204806
        16G:0  Not Visible                 9  (M)   
        03H:0  Not Visible                 a  (M)   
        14H:0  Not Visible                 a  (M)   
0BC2    01G:0  Not Visible                 a  (M)    204806
        16G:0  Not Visible                 a  (M)   
        03H:0  Not Visible                 b  (M)   
        14H:0  Not Visible                 b  (M)   
0BCC    01G:0  Not Visible                 b  (M)    204806
        16G:0  Not Visible                 b  (M)   
        03H:0  Not Visible                 c  (M)   
        14H:0  Not Visible                 c  (M)   
0BD6    01G:0  Not Visible                 c  (M)    204806
        16G:0  Not Visible                 c  (M)   
        03H:0  Not Visible                 d  (M)   
        14H:0  Not Visible                 d  (M)   
0BE0    01G:0  Not Visible                 d  (M)    204806
        16G:0  Not Visible                 d  (M)   
        03H:0  Not Visible                 e  (M)   
        14H:0  Not Visible                 e  (M)   
0BEA    01G:0  Not Visible                 e  (M)    204806
        16G:0  Not Visible                 e  (M)   
        03H:0  Not Visible                 f  (M)   
        14H:0  Not Visible                 f  (M)   
0C32    01G:0  Not Visible                13  (M)     81923
        16G:0  Not Visible                13  (M)   
        03H:0  Not Visible                14  (M)   
        14H:0  Not Visible                14  (M)   
0D6E    01G:0  Not Visible                 f  (M)    102413
        16G:0  Not Visible                 f  (M)   
        03H:0  Not Visible                10  (M)   
        14H:0  Not Visible                10  (M)   
0D72    01G:0  Not Visible                10  (M)    102413
        16G:0  Not Visible                10  (M)   
        03H:0  Not Visible                11  (M)   
        14H:0  Not Visible                11  (M)   
1081    01G:0  Not Visible                 5  (M)    588802
        16G:0  Not Visible                 5  (M)   
        03H:0  Not Visible                 5  (M)   
        14H:0  Not Visible                 5  (M)   
1086    01G:0  Not Visible                 6  (M)    588802
        16G:0  Not Visible                 6  (M)   
        03H:0  Not Visible                 6  (M)   
        14H:0  Not Visible                 6  (M)   
14D3    01G:0  Not Visible                 7  (M)    225281
        16G:0  Not Visible                 7  (M)   
        03H:0  Not Visible                 7  (M)   
        14H:0  Not Visible                 7  (M)   
16F4    01G:0  Not Visible                 8  (M)    774145
        16G:0  Not Visible                 8  (M)   
        03H:0  Not Visible                 8  (M)   
        14H:0  Not Visible                 8  (M)   
1E89    01G:0  Not Visible                11  (M)     81923
        16G:0  Not Visible                11  (M)   
        03H:0  Not Visible                12  (M)   
        14H:0  Not Visible                12  (M)   
1E8D    01G:0  Not Visible                12  (M)     81923
        16G:0  Not Visible                12  (M)   
        03H:0  Not Visible                13  (M)   
        14H:0  Not Visible                13  (M)   
                                                    -------
Total Capacity                                      6467669

Note the "Initiator Group Name" field has the * in the end and is not the last field ( its always the 3rd field )

Also ...in the case above ,can i get the last "port" field as 01G:0_16G:0_03H:0_14H:0

Thnks again

Other way:

awk 'BEGIN{print "Symmetrix ID,DEV,Storage Group Name,Port Group Name,Initiator Group Name,Masking View Name,Port"}
{sub(/:/,": ")}
/Symmetrix/{a=$4}
/Masking View Name/{b=$5}
/Initiator Group Name/{c=$5}
/Port Group Name/{d=$5}
/Storage Group Name/{e=$5}
/Not Visible/{print a","$1","e","d","c","b","$2}' input

Regards

Thanks cgkamal ..... but it does not work in the 2nd scenario i mentioned ...

Modified the code of cgkmal,Hope it will work for both cases. In your second inputfile, there is no Symmetrix Id.

 awk 'BEGIN{print "Symmetrix ID,DEV,Storage Group Name,Port Group Name,Initiator Group Name,Masking View Name,Port"}
{sub(/:/,": ")}
/Symmetrix/{a=$4}
/Masking View Name/{b=$5}
/Initiator Group Name/{c=$5}
/Port Group Name/{d=$5}
/Storage Group Name/{e=$5}
/Not Visible/{if(! /^ /){dev=$1;}print a","dev","e","d","c","b",01G:0_16G:0_03H:0_14H:0"}' testfilee

Thanks pravin ,the second case i mentioned is an example , there are more records like that ..with diff fields , so can't hardcode the port field .There is only one Symmetrix Id field ...the very first one
thx

How about this:

awk '
BEGIN { OFS=",";
  print "Symmetrix ID,DEV,Storage Group Name,Port Group Name,Initiator Group Name,Masking View Name,Port" 
  split("SymmetrixID:,StorageGroupName,PortGroupName,InitiatorGroupName,MaskingViewName", T, ","); 
  for(i in T) GRP[T]=i; }

($1$2$3 in GRP) { val=$1$2$3; gsub(".*:", "", $0); ID[GRP[val]]=$1 }
/^ *---/ {getdev=0}
getdev&&/^   /  { print ID[1],dev,ID[2],ID[3],ID[4],ID[5],$1; next }
getdev { dev=$1;  print ID[1],dev,ID[2],ID[3],ID[4],ID[5],$2 } 
/^------/ { getdev=1 }' infile

[/LEFT]
[/LEFT]

Thanks Chubler ... as always ... ur solution works !!