#!/usr/bin/awk -f BEGIN { a=b=c=0 } FILENAME==ARGV[1] { a++ res1[a]=$1 hdexp[a]=$2 hiexp[a]=$4 cexp[a]=$6 } FILENAME==ARGV[2] { b++ res2[b]=$1 hdtbl[b]=$3 hitbl[b]=$5 ctbl[b]=$7 } END { for (i=1; i<=a; i++) { for (j=1; j<=b; j++) { if (res1[i]==res2[j]) { dif1=hdtbl[j]-hdexp[i] dif2=hitbl[j]-hiexp[i] dif3=ctbl[j]-cexp[i] printf"%4d %7.4f %7.4f %7.4f\n", res1[i], dif1, dif2, dif3 break } } } }