Hi all.
I am trying to create a script, or command(s) that will parse/extract some data from a text file. In this case, it is an ldap export from WebLogic. Below is an example of the entries in the file (some characters have been changed to mask the actual values). There are around a thousand of these entries, all the same format. This is the first two.
dn: uid=1111,ou=people,ou=@realm@,dc=@domain@
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
objectclass: wlsUser
cn: 1111
sn: 1111
uid: 1111
userpassword:: not real
createTimestamp: 201508210200Z
creatorsName: cn=Admin
wlsMemberOf: cn=PayablesProcessor,ou=groups,ou=@realm@,dc=@domain@
wlsMemberOf: cn=InvoiceViewer,ou=groups,ou=@realm@,dc=@domain@
wlsMemberOf: cn=PayablesSpecialist,ou=groups,ou=@realm@,dc=@domain@
wlsMemberOf: cn=SupplierMaintenance,ou=groups,ou=@realm@,dc=@domain@
wlsMemberOf: cn=MailRoom,ou=groups,ou=@realm@,dc=@domain@
wlsMemberOf: cn=Administrators,ou=groups,ou=@realm@,dc=@domain@
modifyTimeStamp: 201600292340Z
modifiersName: cn=Admin
dn: uid=2222,ou=people,ou=@realm@,dc=@domain@
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
objectclass: wlsUser
cn: 2222
sn: 2222
uid: 2222
userpassword:: not real
wlsMemberOf: cn=InvoiceViewer,ou=groups,ou=@realm@,dc=@domain@
modifyTimeStamp: 201507121255Z
modifiersName: cn=Admin
createTimestamp: 201508210200Z
creatorsName: cn=Admin
What I am trying to do is get the 'sn:' value and the 'wlsMemberOf:' ... in that order. I've come up with a few commands that pull these values. But, I need some logic to get all of the neccesary values, formatted the way I need it.
strings <file_name>.dat | grep sn | gawk '{print $2}' | sort (would give):
1111
2222
strings <file_name>.dat | grep wlsMemberOf | gawk '{print $2}' | cut -d, -f1 | cut -d= -f2 (would give):
PayablesProcessor
InvoiceViewer
PayablesSpecialist
SupplierMaintenance
MailRoom
Administrators
InvoiceViewer
What I need would look something like this:
1111 PayablesProcessor
1111 InvoiceViewer
1111 PayablesSpecialist
1111 SupplierMaintenance
1111 MailRoom
1111 Administrators
2222 InvoiceViewer
Any help is appreciated.
Thanks,
Charles