title: How to check value of a column lies between values of two columns in other file and print corresponding value from column in Unix?
body: <p>I have two files to be compared. I found how to compare columns and print according to condition. My problem at hand is that I have to check if the value of column[2] in file1 lies between value in file2 defined as a range in two columns, col [2] col[3]. If that is true, then I should print column[4] of file 2 in my file1.</p>
  
  <h3>file1:</h3>
  
  <pre><code>scaffold1_size11    12
  scaffold2_size22    26
  scaffold3_size33    67
  </code></pre>
  
  <h3>file2:</h3>
  
  <pre><code>scaffold1_size11    1   10  Os01
  scaffold1_size11    12  20  Os08
  scaffold1_size11    29  59  Os07
  scaffold2_size22    17  24  Os09
  scaffold2_size22    27  38  Os09
  scaffold2_size22    39  60  Os10
  scaffold2_size22    67  78  Os10
  scaffold3_size33    15  27  Os03
  scaffold3_size33    29  62  Os08
  scaffold3_size33    64  78  Os02
  scaffold3_size33    80  98  Os01
  </code></pre>
  
  <h3>desired output:</h3>
  
  <pre><code>scaffold1_size11    12  Os08
  scaffold2_size22    26
  scaffold3_size33    67  Os02
  </code></pre>
  
  <p>How should this be done?</p>