![]() |
|
|
grep unix.com with google
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Our Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
Compare two files using awk or sed, add values in a column if their previous fields are same
Hi All,
I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output files as follows In my above example, each row in file1 has 6 fields and each row in file2 has 3 fields. I should compare field2 in both the files. If field2 is same in both the files then i should get the third field in file2 as the last field in file1. output: abc,def,ghi,5,jkl,mno,kishore pqr,stu,ghi,10,vwx,xyz,mike cba,ust,ihg,4,cdu,oqw,krishna Also, If field3 in file1 is same as field3 in the next line then the field4 should add upto field4 in the next line and i should get a unique output as follows ouput: abc,def,ghi,15,jkl,mno cba,ust,ihg,4,cdu,oqw can somebody please help me with this as i require it pretty urgently. I am using sun solaris. If we can get the output using sed or awk that would be great. Any other way is also appreciated. Thanks in advance.......... |
|
||||
|
Double post, thread closed. Continued here
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Compare two files using awk or sed, add values in a column if their previous fields are same | yerruhari | Shell Programming and Scripting | 3 | 11-08-2009 10:53 PM |
| plus values from two files differient fields. | jimmy_y | Shell Programming and Scripting | 4 | 06-23-2009 05:43 AM |
| How to read and compare multiple fields in a column at the same time | ahjiefreak | Shell Programming and Scripting | 1 | 06-19-2008 12:08 PM |
| Compare 2 files through multiple fields | newinawk | Shell Programming and Scripting | 4 | 06-12-2008 05:34 PM |
| I need to extract last column of a file and compare the values | vukkusila | Shell Programming and Scripting | 4 | 08-04-2007 12:21 PM |