again stucked with text processing (sed/awk/perl), copy the line and change
from the following file;
dn: CN=Muhammad Hadhi K.M,OU=IT Dept,OU=Example Company H.O,DC=example,DC=com cn: Muhammad Hadhi K.M sn: Hadhi l: Calicut title: IT Manager postalCode: 5456 postOfficeBox: 3434 physicalDeliveryOfficeName: IT Department telephoneNumber: +111 1 111111 Ext:111 facsimileTelephoneNumber: +222 2 222222 givenName: Muhammad department: IT company: Example Company Ltd. proxyAddresses: SMTP:hadhi@example.com streetAddress: P.O.Box 3434 mobile: +4444 4444 4444 i need to copy the value of cn: and put a new line under the cn: line with the "displayName: Muhammad Hadhi K.M" cn: Muhammad Hadhi K.M displayName: Muhammad Hadhi K.M there are almost 1500 entries. the cn: value and displayName: value must be same for each addresses any idea??? i think perl can do this task easily |
sed -r 's/cn\:(.*)/&\ndisplayname:\1/' input_file_name
|
Thank you lokesh, it worked for me... now can u pls explain that command. I didnt understand how it works...???
|
Quote:
|
To learn sed I suggest Sed: An Introduction And Tutorial. Here is an alternative solution in awk:
Code:
awk '{print} /cn:/{name = gensub("cn:","displayName:",1,$0); print name}' file |
All times are GMT -5. The time now is 07:53 PM. |