Read from text file;format and print output

Hi Following is the assumed input...

Symmetrix ID        : 12345

Originator Port wwn : 123456789
User-generated Name : 123456789/123456789

Sym Dev  Dir:P                                            LUN
------  -----  -----------------------  ----  ---  ---- ----  ----  -------
1234     8A:1  Not Visible                 0    0    61  N/A  (M)     17261
5678     8C:1  Not Visible                 0    0    75  N/A  (M)     25892
9123     8C:1  Not Visible                 0    0    80  N/A  (M)    153563
4567     8A:1  Not Visible                 0    0    67  N/A          219
Symmetrix ID        : 12345

Originator Port wwn : 123456789
User-generated Name : 123456789/123456789

Sym Dev  Dir:P                                            LUN
------  -----  -----------------------  ----  ---  ---- ----  ----  -------
1234     8A:1  Not Visible                 0    0    61  N/A  (M)     17261
5678     8C:1  Not Visible                 0    0    75  N/A  (M)     25892

Symmetrix ID        : 12345

Originator Port wwn : 123456789
User-generated Name : 123456789/123456789

Sym Dev  Dir:P                                            LUN
------  -----  -----------------------  ----  ---  ---- ----  ----  -------
1234     8A:1  Not Visible                 0    0    61  N/A  (M)     17261
5678     8C:1  Not Visible                 0    0    75  N/A  (M)     25892
9123     8C:1  Not Visible                 0    0    80  N/A  (M)    153563

I need output as below:

Originator Port WWN        Sym Dev             Dir:P

123456789        1234,5678,9123,4567    8A:1,8C1,8A1,8C1
123456789        1234,5678        8A:1,8C1
123456789        1234,5678,9123        8A:1,8C1,8A1

Please help .tried using awk but dint help

Please explain how we are to determine when colons are to be dropped from entries in the 3rd column of the output, why the output order in the 3rd column doesn't match the output order of the 2nd column of output, and why some occurrences of 8C:1 seem to be randomly changed to 8A1. It would be fairly easy to produce:

123456789 1234,5678,9123,4567 8A:1,8C:1,8C:1,8A:1
123456789 1234,5678 8A:1,8C:1
123456789 1234,5678,9123 8A:1,8C:1,8C:1

but I can't see pattern that would produce the output you need.

Hi Don,

Thanks for checking.
if below is input

Symmetrix ID : 12345

Originator Port wwn : 123456789
User-generated Name : 123456789/123456789

Sym Dev Dir:P LUN
------ ----- ----------------------- ---- --- ---- ---- ---- -------
1234 8A:1 Not Visible 0 0 61 N/A (M) 17261
5678 8C:1 Not Visible 0 0 75 N/A (M) 25892
9123 8C:1 Not Visible 0 0 80 N/A (M) 153563
4567 8A:1 Not Visible 0 0 67 N/A 219
....
...
..
Symmetrix ID : 12345

This will be the format in input file.. what I need is output should ahve Originator Port wwn : 123456789 and numbers under Sym dev and Dir:P columns and WWN in a table format...i.e.,

Originator Port wwn symdev dir:p
123456789 1234,5678,9123,4567,...,...,.. 8A:1,8C:1,8a:1,8c:1

---------- Post updated at 01:41 AM ---------- Previous update was at 01:26 AM ----------

wwn symdev dir.p
12345678 1234,5678,9123,4567 8a:1,8c:1

---------- Post updated at 01:49 AM ---------- Previous update was at 01:41 AM ----------

i am sorry., data is not formatting correctly with spaces..

here is what i need.. from input it should colelct wwn info, list under symdev, list under dir.p columns and print like below

wwn symdev dir.p
xxxx xx,yy,zz xx:x,yy:y

under dir:p xx:x ;yy:y ":'" is pattern how dir : p column is displayed..

If you would use CODE tags as required in this forum it would help with your spacing issues. That wouldn't, however, do anything about inconsistent capitalization. I think this does what you want, even though the output produced doesn't match any of the output you specified:

awk '
function ps() {
        if(wwn) print wwn, sym, dir
        else    print "wwn symdev dir.p"
        dir = sym = wwn = ""
}
/^Originator Port/ {
        ps()
        wwn = $NF
}
$2 ~ /:/ {
        sym = (sym ? sym "," : "") $1
        dir = (dir ? dir "," : "") $2
}
END {   ps()
}' input

If you are using a Solaris/SunOS system, use /usr/xpg4/bin/awk or nawk instead of awk .

Thanks a lot!! this worked.