![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
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 | 1 Week Ago 10:53 PM |
| Compare two files using awk or sed, add values in a column if their previous fields are same | yerruhari | UNIX for Dummies Questions & Answers | 1 | 2 Weeks Ago 08:52 AM |
| plus values from two files differient fields. | jimmy_y | Shell Programming and Scripting | 4 | 06-23-2009 04: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 11:08 AM |
| I need to extract last column of a file and compare the values | vukkusila | Shell Programming and Scripting | 4 | 08-04-2007 11:21 AM |
![]() |
|
|
LinkBack | 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.......... |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|