numeric range comparisons

I have two files.And a sort of matrix analysis.

Both files have a string followed by two numbers:

File 1:
A 2 7
B 3 11
C 5 10

......
File 2:
X 1 10
Y 3 5
Z 5 9

What I'd like to do is for each set of numbers in the second file indicate if the first or second number (or both) in the first file falls between or is equal to those numbers in the second file.

e.g. print our:

X 1 10: A_first A_second B_first C_first C_second
Y 3 5: B_first C_second
Z 5 9: A_second C_first

My general idea was to open 3 arrays from the 1st file and use an 'if' comparison to the values in the second file but I really don't know what I'm doing.

Thank you for any help. :confused:

What do you want for output?

Output should be something to indicate the string in File 1 and which number(s) first second or both in the line with that string have hit appended to the end of the line in File 2

e.g.

X 1 10: A_2 A_7 B_3 C_5 C_10
Y 3 5: B_3 C_5
Z 5 9: A_7 C_5

BTTT

Ok I really have no idea what I'm doing but I'm trying things. I need to figure out how to push all 3 strings through the array at one time:

awk '
NR==FNR{
a[NR]=$0
next
}
{
for(h=1;h<NR;h++)
for(i=1;i<NR;i++)
for(j=1;j<NR;j++)

              print $1, $2, $3 ":" if \($2 =&lt; a [i]=&lt; $3\) print a[h] "_" a [i]if \($2 =&lt; a[j]=&lt;$3\) print a[h] "_" a[j]
         \}

' infile1 infile2 > outfile

Bttt for this week.

I guess I'll need to do sometprint $1, $2, $3 ":" if ($2 < a [i]&& a[i]=< $3) print a[h] "" a [i]if ($2 < a[j] && a[j]<$3) print a[h] "" a[j]
}
' infile1 infile2 > outfilehing like:

Can anyone help me figure out how to pass more than one string through the loop array??

Thanks.

Somehow this just sounds like you would end up with a different and easier problem if you thought about it a little bit. What is it that you are trying to accomplish, on a higher level of abstraction?

I'm trying to figure out how to push 2 (or more) strings through an array at the same time. So that I can track a name and number(s).

Not the most efficient as it makes as many passes through File1 as there are lines in File2 but give it a shot for grins.

while read x y z
do
   S=$x" "$y" "$z":"
   while read a b c
   do
     if [ $b -ge $y -a $b -le $z ]; then
        S=$S" "$a"_"$b
     fi

     if [ $c -ge $y -a $c -le $z ]; then
        S=$S" "$a"_"$c
     fi
   done < File1
   echo $S
done < File2