I have a file with user name, telephone numbers and the addn for each user where each is separated by a blank line such as:
________________________________________________________________________________
dn: cn=John Doe,ou=employee,o=abc,c=AN
telephonenumber: +1 432 111 2222
addn: CN=John Doe,OU=Users,DC=xxx,DC=abc,DC=com
dn: cn=Jane Doe,ou=employee,o=abc,c=AN
telephonenumber: +44 1293 112233
telephonenumber: +44 1293 112244 (SINet)
telephonenumber: +44 1293 112244
addn: CN=Jane Doe,OU=Users,DC=xxx,DC=abc,DC=com
dn: cn=IPT-GB0000-DP2,ou=role,O=abc,C=AN
telephonenumber: +44 1293 555555
telephonenumber: +44 1293 333333
telephonenumber: +44 1293 444444
addn: CN=IPT-GB0000-DP2,CN=Users,DC=xxx,DC=slb,DC=com
dn: cn=IPT-GB8888-DP3,ou=role,O=abc,C=AN
telephonenumber: +44 1293 777777
telephonenumber: +44 1293 999999 (SINet)
telephonenumber: +44 1293 000000
addn: CN=IPT-GB8888-DP3,CN=Users,DC=xxx,DC=abc,DC=com
________________________________________________________________________________
for each group in the file I need to print out the:
addn:
telephonenumber:
The problem I have is that I need to only print out one telephone number for each user.
If the user has multiple phone numbers then I need to take the line that contains (SINet) to use for the telephone number and if it does not contain (SINet) in any of the telephone numbers then I need to use the first line of the telephone numbers for that user.
So for these 4 examples I would get output such as:
addn: CN=John Doe,OU=Users,DC=xxx,DC=abc,DC=com
telephonenumber: +1 432 111 2222
addn: CN=Jane Doe,OU=Users,DC=xxx,DC=abc,DC=com
telephonenumber: +44 1293 112244 (SINet)
addn: CN=IPT-GB0000-DP2,CN=Users,DC=xxx,DC=slb,DC=com
telephonenumber: +44 1293 555555
addn: CN=IPT-GB8888-DP3,CN=Users,DC=xxx,DC=abc,DC=com
telephonenumber: +44 1293 999999 (SINet)
The script I made is printing out the addn and phone number but always ends up with the first phone number where if there is a phone number with a tag of (SINet) I need to use that one, if not then the first line is needed.
Thanks for any help on this!!
That sure works for that, still have a numbers of things to work out but that is a big help on that part.
Thanks!!!