![]() |
|
|
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 |
| How to compare a field value of a same column? | gobinath | Shell Programming and Scripting | 6 | 05-06-2009 02:39 AM |
| compare the column from 3 files and merge that line | ganesh_mak | Shell Programming and Scripting | 8 | 04-14-2008 08:56 AM |
| awk compare column between 2 files | phamp008 | Shell Programming and Scripting | 3 | 01-18-2008 12:24 AM |
| 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 |
| Compare Column value from Two Different Files | hanie123 | Shell Programming and Scripting | 7 | 04-02-2007 10:34 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
awk column compare
I've been banging my head against the wall to accomplish the following. Given two files:
File a.txt 12345 hello 32324 there File b.txt 12345 stuff 45454 howdy 32324 joe If column 1 matches between the two files, then print only the entire line of the 2nd file (b.txt in this example So the desired output in this case would be:12345 stuff 32324 joe I've been working with the follow as a basic start, but seem to have come up with every combination except that which I'm looking for: awk 'NR==FNR{++a[$1];next}!a[$1]' a.txt, b.txt > c.txt As you probably guessed this is based on an 'almost' solution google search - in the meantime I've purchased the O'Reilly book and am plowing through it - but in the meantime I really need to get this done... so, anyone kind enough to share a (hopefully somewhat commented) snippet would be most appreciated. Thanks, Al |
![]() |
| Bookmarks |
| Tags |
| awk, column, linux, regex |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|