Using Sed to replace some text and add test

fritz1968

New Member
Joined
Oct 21, 2019
Messages
1
Reaction score
0
Credits
0
Hello,

I have the following records in an LDIF file (actually, I have thousands of these records in the file):

dn: cn=userA,ou=users,ou=vault,o=company
changetype: modify
add: attribute1
attr2: userA

dn: cn=userB,ou=users,ou=vault,o=company
changetype: modify
add: attribute1
attr2: userB


I want to replace the attr2: string and add to the end of that line so that it looks like the following:

dn: cn=userA,ou=users,ou=vault,o=company
changetype: modify
add: attribute1
attribute1: someText:userA,moreText

dn: cn=userB,ou=users,ou=vault,o=company
changetype: modify
add: attribute1
attribute1: someText:userB,moreText


Note that the userA and userB (and each of these will be different in the entire file) are embedded in the "text" that was added to the front/end of the original line.

How do I do this? will Sed work? Awk maybe? any help would be much appreciated.
 



Staff online

Members online


Top