I have a file with a number of records from an LDAP search and need to retrieve two lines. But the two lines are not always on the same row and one line does not always exits.
Example:
uid=techie,ou=people,dc=example,dc=com
objectClass=posixAccount
objectClass=shadowAccount
objectClass=account
objectClass=top
uid=techie
cn=techie
uidNumber=14
gidNumber=27
gecos=userx
homeDirectory=/export/home/userx
loginShell=/usr/bin/ksh
uid=ipsec,ou=people,dc=example,dc=com
objectClass=posixAccount
objectClass=shadowAccount
objectClass=account
objectClass=top
uid=ipsec
cn=ipsec
uidNumber=16
gidNumber=1
homeDirectory=/etc/ipsec
loginShell=/usr/bin/ksh
uid=guest,ou=people,dc=example,dc=com
uidNumber=55
objectClass=posixAccount
objectClass=shadowAccount
objectClass=account
objectClass=top
uid=guest
cn=guest
gidNumber=23
gecos=Guest User
homeDirectory=/export/home/guest
loginShell=/usr/bin/ksh
Notice how the records are different. What I want to return is the cn and gecos from each record.
So it would return:
cn=techie
gecos=userx
cn=ipsec
cn=guest
gecos=Guest User
Thanks!!
Example:
uid=techie,ou=people,dc=example,dc=com
objectClass=posixAccount
objectClass=shadowAccount
objectClass=account
objectClass=top
uid=techie
cn=techie
uidNumber=14
gidNumber=27
gecos=userx
homeDirectory=/export/home/userx
loginShell=/usr/bin/ksh
uid=ipsec,ou=people,dc=example,dc=com
objectClass=posixAccount
objectClass=shadowAccount
objectClass=account
objectClass=top
uid=ipsec
cn=ipsec
uidNumber=16
gidNumber=1
homeDirectory=/etc/ipsec
loginShell=/usr/bin/ksh
uid=guest,ou=people,dc=example,dc=com
uidNumber=55
objectClass=posixAccount
objectClass=shadowAccount
objectClass=account
objectClass=top
uid=guest
cn=guest
gidNumber=23
gecos=Guest User
homeDirectory=/export/home/guest
loginShell=/usr/bin/ksh
Notice how the records are different. What I want to return is the cn and gecos from each record.
So it would return:
cn=techie
gecos=userx
cn=ipsec
cn=guest
gecos=Guest User
Thanks!!