Hii,
I have a file like this--
dn: cn=Anandmohan Singh,ou=addressbook,dc=thbs,dc=com
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
cn: Anandmohan Singh
givenName: Anandmohan
mail: anand_ms@thbs.com
mobile: 9986010455
o: Torry Harris
ou: null
physicalDeliveryOfficeName: ST-6th Floor
sn: Singh
telephoneNumber: 41827200 Extn: 7400
title: Associate Software Engineer - Trainee
uid: 1432
dn: cn=Riteshkumar Mohanty,ou=addressbook,dc=thbs,dc=com
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
cn: Riteshkumar Mohanty
givenName: Riteshkumar
mail: ritesh_m@thbs.com
mobile: 9916953109
ou: null
physicalDeliveryOfficeName: ST-6th Floor
sn: Mohanty
telephoneNumber: 41827200 Extn: 7400
title: Associate Software Engineer - Trainee
uid: 1418
Here i want to replace the line o: Torry Harris with o: Torry arris Business Solutions and in file there are places where this line is not there after the Mobile number,so i want to insert the line as --o: Torry arris Business Solutions. i can replace it easily with sed but how i can insert the line after that.
Thanks
Hi,
if input is
givenName: Anandmohan
mail: anand_ms@thbs.com
mobile: 9986010455
o: Torry Harris
ou: null
physicalDeliveryOfficeName: ST-6th Floor
sn: Singh
o/p should be
givenName: Anandmohan
mail: anand_ms@thbs.com
mobile: 9986010455
--o: Torry arris Business Solutions
ou: null
physicalDeliveryOfficeName: ST-6th Floor
sn: Singh
Am I Right. If not send a sample output
Thanks
Penchal
This file is very big infact, if i start doing it with VI it will consume plenty of time.
Yes penchal u r right about the output,one more thing there are places after mobile number where the line is not there we need to insert the line there.
Thanks
Try this:
awk '/^mobile: /{
print; getline; print "o: Torry arris Business Solutions"
if(substr($1,1,2) == "o:"){next}
}1' file
Regards
Hi,
You can build simple solution in perl for this.
Please let me know if you need source code for it.
Thanks
i dont have perl installed in my machine,so i will appericiate if i get anything in unix only.
Anyway thanks for paying attention to the problem.
What does 1 signifies here.
awk evaluates after the last close brace the 1 as true and the prints the entire line by default.
Regards