Bash: Filter lines by matching to number range
With single GNU awk
program (since Gawk
v4.0):
awk 'NR==FNR{ a[$1][$2]; next }
$1 in a{
for (i in a[$1])
if (i >= $2 && i <= $3) { print $0; break }
}' test db
The output:
1 6408 8000
2 44839 50247