![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Merge Two Files based on First column | apjneeraj | Shell Programming and Scripting | 10 | 04-13-2009 01:44 AM |
| concatenate files with identifier | yonhk | UNIX for Dummies Questions & Answers | 1 | 11-16-2008 10:51 PM |
| Merging column files | swapna321 | Shell Programming and Scripting | 1 | 06-27-2008 07:12 AM |
| Merging two files with a common column | manneni prakash | Shell Programming and Scripting | 2 | 06-20-2008 03:19 AM |
| merging two files based on some key | Vandana Yadav | Shell Programming and Scripting | 1 | 02-03-2006 09:45 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
merging column from two files based on identifier
Hi,
I have two files consisting of two columns. So I want to merge column 2 if column 1 is the same. So heres an example of what I mean. FILE1 driver 444 car 333 hat 222 FILE2 driver 333 car 666 hat 999 So I want to merge the column 2's together so there is no gap... so the output file will look like this... driver 444333 car 333666 hat 222999 Currently I am using this script but I can only get it to work for column 2 if column 1 is removed. awk 'NR==FNR { a[c=FNR]=$0; next } { printf "%-8s%s\n", a[FNR], $0 } END { for(i=FNR+1;i<=c;i++) print a[i] }' FILE2.txt FILE2.txt > output.txt Last edited by phil_heath; 06-12-2009 at 12:51 AM.. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|