title: Replace values from other columns if value of one column is null using awk/sed
body: <p>I am trying to modify a tab delimited file by replacing the value of 2 columns separated by ":" where there is a null value in one column: </p>
  
  <p>Start with this file:</p>
  
  <pre><code>id1 id2 pos1    pos2
  749 2847443 21  13517135
  862 2821796 21  13571669
  997     21  13636494
  1095    2821826 21  13661335
  1131        21  13678797
  </code></pre>
  
  <p>I would like to modify column 2 to get this:</p>
  
  <pre><code>id1 id2 pos1    pos2
  749 2847443 21  13517135
  862 2821796 21  13571669
  997 21:13636494 21  13636494
  1095    2821826 21  13661335
  1131    21:13678797 21  13678797
  </code></pre>
  
  <p>The problem is also that there is no blank space (" ") indicating a null value. 
  For now I have not even been able to substitute the value of column 2 with column 3 when it is null...</p>
  
  <p>I have tried using sed:</p>
  
  <pre><code>sed -e 's/\t\t/\t$3\t/g' input.txt &gt; output
  </code></pre>
  
  <p>Which works but it just substitutes the text '$3' and I can't find how to substitute the values of $3:$4 instead. </p>
  
  <p>I have also tried awk: </p>
  
  <pre><code>awk 'BEGIN {
    IFS = OFS = "\t"
   }
  {
      for (column = 2; column &lt;= NF; ++column) {
      if ($column == "") {
          $column = $3
      }
   }    
   print 
  }         
  '
  input.txt &gt; output
  </code></pre>
  
  <p>But this does not work either (it does nothing actually neither using "" nor " "...)</p>
  
  <p>Can you please help me?
  Thank you.</p>