title: Substract 2 values from same column if 2 fields match on same line
body: <p>I've got a formatted file in this way:</p>
  
  <pre><code>1 223614 225119.537745 Engine45
  2 223614 225121.082392 Engine45
  3 223614 225124.440309 Engine45
  4 223614 225124.763890 Engine45
  5 223621 225124.933927 Engine46
  6 223614 225124.934205 Engine45
  7 223614 225125.354857 Engine45
  8 223614 225127.603434 Engine45
  .
  .
  .
  </code></pre>
  
  <p>I'm trying to make a awk/shell that takes that 1) verify columns 2 and 4 if there equal in the same line, and if this applies, 2) substract the second found value on column 2 with the first found column 1, should be like this:</p>
  
  <p>1st line found by 1):</p>
  
  <pre><code>1 223614 225119.537745 Engine45
  </code></pre>
  
  <p>2nd line found by 1):</p>
  
  <pre><code>2 223614 225121.082392 Engine45
  </code></pre>
  
  <p>Output should be the answer of this:</p>
  
  <p>225121.082392 - 225119.537745 = 1.544647</p>
  
  <p>The next output should be :</p>
  
  <p>3rd line find by 1):</p>
  
  <pre><code>3 223614 225124.440309 Engine45
  </code></pre>
  
  <p>4th line find by 1):</p>
  
  <pre><code>4 223614 225124.763890 Engine45
  </code></pre>
  
  <p>Output: 225124.763890 - 225124.440309 = 0.323581</p>
  
  <p>And successively with all records in file provided.</p>
  
  <p>I believe that 1) i could make it work but 2) is really getting hard for me but if someone can give a lead how to get  could be very useful, i know basics from shell and awk if it helps, but i'm open to get done on another tools like perl .</p>
  
  <p>Regards</p>