calculation using awk or shell script in between the numbers

file A

E969K
D223L
E400L
E34L

file B

predicted 3
1  250
251 500
501 1000

The output should be

E969K   501 1000
D223L 1      250
E400L  251   500
E34L   1    250

I tried in this way

 
tr -d  [A-Z]  <file A 
then in shell script 
exec<$1
while read line
do
echo "awk '\$1<=$line && \$2>=$line' $2" > FOO
./FOO >> XXXXX
done

any other easy option can be done

Hi
If the order of the result is not a concern for you, try this:

awk 'NR==FNR{a[i++]=$0;next;}{for(j in a){x=a[j];gsub(/[A-Z]/,"",x);x=int(x);if ($1<x && $2>x) print a[j],$0;}}' i=1 fileA fileB

Guru

1 Like