Results 1 to 2 of 2
Hello all,
I have an export from an OpenLDAP directory and want to modify all users to accommodate a new scheme.
Example user.ldif is:
dn: cn=Firstname Lastname,ou=Users,dc=bca,dc=edu,dc=gr
objectClass: inetOrgPerson
objectClass: ...
- 11-17-2008 #1Just Joined!
- Join Date
- Dec 2003
- Location
- Greece
- Posts
- 43
SED +ldif
Hello all,
I have an export from an OpenLDAP directory and want to modify all users to accommodate a new scheme.
Example user.ldif is:
dn: cn=Firstname Lastname,ou=Users,dc=bca,dc=edu,dc=gr
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: person
objectClass: organizationalPerson
objectClass: top
givenName: Firstname
sn: Lastname
cn: Firstname Lastname
uid: flastname
userPassword: {CRYPT}dfdfsdf2lRBeF.
uidNumber: 1029
gidNumber: 100
homeDirectory: /home/flastname
loginShell: /bin/false
mail: flastname@mydomain.com
What I need is to replace the cn=Firstname Lastname with uid=flastname in the whole file where ofcourse the value of Firstname Lastname changes per user.
This needs to be done in the whole file (many users). Is there a way with SED to achieve this in order to avoid editing the fil by hand?
- 11-18-2008 #2Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
I'm pretty sure this could be done with sed, but it would be much easier to do it with awk or perl (or even bash).


Reply With Quote