title: Compute estimated time left from specific string, bash scripting
body: <p>I'm looking for an elegant way of computing estimated time left for a program to finish. I have a log.txt file where all kind of parameters are written and which steps are finished so far. When the photon launching phase starts, date, time and percentage reached so far is written e.g.</p>
  <pre><code>10/11/2020 02:48:29.079   (12.3 GB) Launched primary emission photon packets: 43.0%
  </code></pre>
  <p>The idea is to use the first and latest date and percentage and then to simply apply a linear scaling taking correctly taking into account the change of date (that could be arbitrary). Time is given in day/month/year hh:mm:ss format.</p>
  <pre><code>10/11/2020 02:30:24.669   (12.3 GB) Launched primary emission photon packets: 0.2%
  10/11/2020 03:01:12.047   (12.3 GB) Launched primary emission photon packets: 73.1%
  </code></pre>
  <p>p2 = 73.1%</p>
  <p>p1 =  0.2%</p>
  <p>t2 = 10/11/2020 03:01:12.047</p>
  <p>t1 = 10/11/2020 02:30:24.669</p>
  <p>When solved, one obtains:</p>
  <p>t_finish = t(100%) = (t2 - t1)/(p2 - p1)<em>100% + (p2</em>t1 - p1*t2)/(p2 - p1)</p>
  <p>Finally, the time left is t_left = t_finish - t2</p>
  <p>The output should be in seconds. Below is a part of the log.txt file that contains time and percentage reached. A solution to this problem could be very useful for future time and date calculations.</p>
  <pre><code>......
  ......
  10/11/2020 02:30:18.006   (12.3 GB) Starting primary emission...
  10/11/2020 02:30:18.006   (12.3 GB) Launching 3e7 primary emission photon packets
  10/11/2020 02:30:24.669   (12.3 GB) Launched primary emission photon packets: 0.2%
  10/11/2020 02:30:31.385   (12.3 GB) Launched primary emission photon packets: 0.4%
  ......
  ......
  10/11/2020 03:01:12.047   (12.3 GB) Launched primary emission photon packets: 73.1%
  ......
  ......
  </code></pre>