here is an examplar file. I want to print the line where the number in column 2 within a range defined by two shell variables.
Test    198     A   0   
Test    199     A   2   
Test    2       A   0
Test    202     A   22  
Test    122859  G   199
Test    198589  A   0   
For exemple, if $start=198 and $end=202, I only want those lines:
Test    198 A   0   
Test    199 A   2   
Test    202 A   22  
Not
Test    122859      G   **199**
Test    **198**589  A   0   
I tried several combination of awk and sed and haven't find one that works properly in my script.
sed -n -e "/\t$start\t/,/\t$end\t/p" file
This one was my initial try, working really well except in this case 
Test    122859      G   **199**
So I tried with awk and it wasn't succesful, especially to deal with that case:
Test    **198**589  A   0   
awk '$2 == "$start", $2 == "$end"' file or awk "$2 ~ /\t$start\t/,/\t$end\t/" file
Is there a way to correct one of these to make it do what I need ?
Thanks
 
     
    