The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



Thread: Files
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 05-14-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
This is a FAQ, search the forums for NR==FNR

Code:
awk 'NR==FNR { b[$1 $2] = $3 ; next }
{ if (b[$1 $2]) $3 = b[$1 $2]; print  }' file2.txt file1.txt

Last edited by era; 05-14-2008 at 07:59 AM. Reason: Changed the logic slightly
Reply With Quote