Hi All, I am new to awk, and having a hard time trying things myself, hope you can help me out. I have file A with two columns, it looks like this:
7000000185249034 1114
7000000185249048 1532690
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.
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
Any advice will be appreciated! Thank you in advance!
0 answers
No answers yet.
Log in to answer this question.
Hello jingjin2203!
We believe that this post does not fit the main topic of this site.
This is text processing. Please search SO/Unix SE
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!