title: How can I convert a logfile entry date into a date in the future in bash
body: <p>I'm sure this answer is obvious but I'm banging my head on it and getting a headache and my Search Foo is failing me… </p>
  
  <p>I have a log file with this date format:</p>
  
  <pre><code>Sep  1 16:55:00 stuff happening 
  Sep  1 16:55:01 THIS IS THE LINE YOU WANT at this time stamp
  Sep  1 16:55:02 more stuff
  Sep  1 16:55:02 THIS IS THE LINE YOU WANT at this time stamp
  Sep  1 16:55:03 blah
  Sep  1 16:55:04 blah and so on…..
  </code></pre>
  
  <p>My ultimate goal is to:</p>
  
  <ol>
  <li><p>Find the last line in the log file with a given string eg:  "THIS IS THE LINE…" this is my "magic time" that I will do calculations on later.</p></li>
  <li><p>Take the date of that line and set a variable that is the date +NN  seconds. The time in the future will usually just short of 24hrs in the future from the time in step 1 so crossing into the next day may happen if that is important.</p></li>
  <li><p>At some point in the script, advance the system clock to the new date/time after which I will be checking for certain events to fire.</p></li>
  </ol>
  
  <p>I know this is way wrong but so far I have figured out how to:</p>
  
  <ol>
  <li><p>Grab the last date stamp for my event.</p>
  
  <p>logDate=<code>cat /logdir/my.log | grep "THIS IS THE LINE" | tail -1 | cut -f1,2,3 -d" "</code></p></li>
  </ol>
  
  <p><strong>Returns: Sept 1 16:55:02</strong></p>
  
  <ol>
  <li><p>Convert the date into a more usable format</p>
  
  <p>logDate2="$(date -d "$logDate" +"%m-%d %H:%M:%S")"; echo $logDate2</p></li>
  </ol>
  
  <p><strong>Returns: 09-17 16:55:02</strong></p>
  
  <ol>
  <li><p>I'm stuck here   - what I want is:</p>
  
  <p>futuredate=<code>$logdate2 + XXXSeconds</code></p></li>
  </ol>
  
  <p>Could someone help me with the time calculation or perhaps point out a better way to do all of this?</p>
  
  <p>Thanks.</p>