![]() |
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 |
| 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 |
| To get an output by combining fields from two different files | smriti_shridhar | Shell Programming and Scripting | 8 | 10-22-2008 07:21 AM |
| Matching and combining two files | sickboy | Shell Programming and Scripting | 3 | 07-17-2008 01:20 PM |
| combining fields in awk | json4639 | Shell Programming and Scripting | 2 | 07-10-2008 03:52 PM |
| Matching and combining two files | p3t3r | Shell Programming and Scripting | 5 | 05-20-2008 11:16 AM |
| combining fields in two text fields | shocker | Shell Programming and Scripting | 3 | 01-16-2008 11:27 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
AWK Matching Fields and Combining Files
Hello!
I am writing a program to run through two large lists of data (~300,000 rows), find where rows in one file match another, and combine them based on matching fields. Due to the large file sizes, I'm guessing AWK will be the most efficient way to do this. Overall, the input and output I'm looking for is similar to to this: File1: *first three columns are coordinates in (x, y, z)* 123 456 678 A B C 234 345 567 D F B 234 456 324 H J K 765 432 987 M N K File2: *the last three columns are coordinates in (x, y, z)* 45 234 345 567 46 765 432 987 47 111 222 333 48 234 345 567 49 987 765 432 50 444 555 666 51 765 432 987 ... and so on Output file: 45 234 345 567 D F B 46 765 432 987 M N K 48 234 345 567 D F B 51 765 432 987 M N K File2 has many more entries than File1, and every coordinate in File1 is located somewhere in File2. The problem I am having is how to search through all of File2 finding where each of the individual File1 coordinates is listed, and the number in column 1 of File2 that corresponds to that coordinate. In a nutshell: Make new file3 Find where File2($2, $3, $4) is equal to File1($1, $2, $3) print to file3 File2($1, $2, $3, $4), File1($4, $5, $6) Thank you! |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|