Hi...
I am fed up in file handing with array for comparing....
1st I want save first 2 columns of file 1
I tried like this,,
{getline< "file1";ln[NR]=$1; lt[NR]=$2}
then I read second file's 1st and 2nd column..and saved like this
and small calculation and initialization
var1 =$1
var2 =$2
calc1= $2-0.1
calc2=$2+0.1
x=0
y=0
for loop for 2nd field of 1st and 2nd column...with a length of file 2's number of lines
for(j=1;j<=file2's length,j++)
now for loop like this for
(i=1;i<file1's array length;i++)
comparison
if lt >=calc1 && lt<=calc2
following if statements
else increment i and again check condition,
once i length reaches file1's array length
print file2's column fields..
then increment of j in 1st for loop
my script is having some mistakes...as I don't know much about either awk or shell...so I could not find where is problem....those who know, please solve my problem
c=`awk 'END{print NR}'file1`
awk '{{getline< "file1";ln[NR]=$1; lt[NR]=$2}}
FNR<=NR{
l1=$1;
la1=$2;
p=la1+0.1;
m=la1-0.1;
x=0;
y=0;
{
for(j=1;j<='$c';j++)
if(lt[j]>=m && lt[j]<=p)
{
if(l1>=ln[j])
x=x+1
if(l1<=ln[j])
y=y+1
}
}
if(x>=1 && y>=1)
print l1,la1,"Wow you are safe..."
}' OFS="\t" file2.dat
I hope you people understand this thread