multiple 'if' statements out of array

I want to do multiple comparisons on a series of numbers from an array:

I send the numbers in file1 through want to print out some info from file2 based on some conditions.

The syntax just isn't correct???

awk '
NR==FNR{
a[NR]=$0
next
}
{
for(i=1;i<NR;i++)
if (a [i]< $7 && a [i]> $8) print $1,
if (a [i]< $8 && a [i]> $9) print $2,
if (a [i]< $5 && a [i]> $4) print $3,

}' file1 file2 > outfile &

any help would be great :confused:

Not sure what you're trying to do here (sure seems to me that there are easier methods) but, for starters, you may want to reference your filenames in your awk procedure blocks or it's going to get messy.

FILENAME == file1 {
    arr[FNR]=$0
    n++
}
FILENAME == file2 {
  for (i=1;i<=n;i++) {
      if ($7 > arr && $8 < arr print $1;
      if ($8 > arr && $9 < arr print $2;
      if ($5 > arr && $4 < arr print $3;
  }
}' file1 file2 > outfile &

note: I didn't test this at all so, no doubt there are errors. Mostly I'm trying to illustrate the use of FILENAME to help with flow control.

t

awk '
   NR==FNR{
          a[NR]=$0
          next
      }
      {
         for(i=1;i<NR;i++) {
            if (a < $7 && a > $8) print $1,
            if (a < $8 && a > $9) print $2,
            if (a < $5 && a > $4) print $3,
         }
}' file1 file2 > outfile &