I have file A with two columns, it looks like this:
7000000185249100 162280 7000000185249048 235500 7000000185249052 755361 7000000185249068 427550 7000000185249070 269102 7000000185249081 291122 And I have file B with three columns, it looks like this:
7000000185249100 1622651 1623044 7000000185249048 235104 235805 7000000185249146 2500324 2502635 7000000185249100 1218818 1221734 7000000185249468 88587 89699 7000000185249239 299691 300277 7000000185249315 769635 769986 7000000185249374 1548986 1549747 So what I wanted to do is to print out lines from file A,
- if the number in first column in file A matches the number in first column in file B, and
- the number in the second column in file A is within the range of the numbers in the second and third columns in file B.
Expected output will be:
7000000185249048 235500 I tried with the following code, but failed.
awk -F '\t' 'FNR==NR{a[$1,$2,$3]=$0;next}{if(b=a[$1, >=$2 && <= $3]){print b}}' file B file A
162280within range of1622651 1623044or1218818 1221734?