954,546 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

comparing and inserting common line in other file

Hi,

I have two files--

file1-


Quote:
dn: cn=Anandmohan Singh,ou=addressbook,dc=thbs,dc=com
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
cn: Anandmohan Singh
givenName: Anandmohan
mail: [email]anand_ms@thbs.com[/email]
mobile: 9986010455
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: [email]ritesh_m@thbs.com[/email]
mobile: 9916953109
ou: null
physicalDeliveryOfficeName: ST-6th Floor
sn: Mohanty
telephoneNumber: 41827200 Extn: 7400
title: Associate Software Engineer - Trainee
uid: 1418

file2:-


Quote:
uid:Password
0050:thbs
1418:thbs
1432:thbs

i have to compare two files and where the uid is same i have to take the password and insert it above the telephone number.

the output should be like this--

uid : 1418 common so insert the password thbs above the line telephonenumber.

larryperl
Junior Poster in Training
51 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

Hey There,

What have you got so far? You should be able to grep the uid/pwd line out of the second file and use awk or sed to insert the necessary line (perhaps use awk to do it all - for the millions of people who are better at using awk than I am :)

, Mike

eggi
Posting Pro in Training
400 posts since Oct 2007
Reputation Points: 102
Solved Threads: 47
 

I am not familiar with awk and very little knowledge of sed i have.So i need help of you guys.

Thanks..

larryperl
Junior Poster in Training
51 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You