script to compare first column of two files and find difference

Hi,

I want to write a script which will compare the 1st column of both the files and will give the difference.
e.g:-
my 1st file contains:

89 /usr
52 /usr/local
36 /tmp
92 /opt
96 /home
27 /etc/opt/EMCom
1 /SF_Appl_01
7 /SF_Data_01
1 /tmpiq

my 2nd file contains:
79 /usr
22 /usr/local
26 /tmp
92 /opt
86 /home
17 /etc/opt/EMCom
1 /SF_Appl_01
7 /SF_Data_01
8 /tmpiq
87 /HS_Appl_01
86 /HS_Data_01

Now I want to find the differnce of 1st column of both the files and notify if differnce is more than 10. Please help me on this.

# awk '{if (FNR != NR) { if (a[$2]) { x = $1 - a[$2]; if ((x >= 0 ? x : -x) > 10) { print "oops at line", FNR, ":", $0 } } } else { a[$2] = $1; } }' file1 file2 

You must change file1 and file2 accordingly with your file names.

nawk '{
if(NR==FNR)
	arr[$2]=$1
else
{
	gap=$1-arr[$2]
	if(gap>10 || gap<-10)
		print $2" "$1"  "arr[$2]"  "gap
}
}' file1 file2

Thanks a lot. It is working fine.