title: Searching for an error in a log for the last 24 hours or current day
body: <p>I have a log, 'test.log', and I want to output only the last 24 hours, or the current days (since midnight) lines where the word 'ERROR' appears.</p>
  
  <p>The contents of the log with the match, look like this:</p>
  
  <blockquote>
    <p>Wed Mar 22 04:20:05 UTC 2017 - ERROR - something has gone wrong. Please check.</p>
  </blockquote>
  
  <p>I have tried the following, however instead of the last 24 hours, I get all lines in the log where the word 'ERROR' appears. </p>
  
  <pre><code>awk -v d="$(date -d '24 hours ago' +'%a %b %d %T %Z %Y')" '$1" "$2&gt;=d &amp;&amp;/ERROR/' test.log
  </code></pre>
  
  <p>I've also tried </p>
  
  <pre><code>awk -v d="$(date -d 'today' +'%a %b %d %T %Z %Y')" '$1" "$2&gt;=d &amp;&amp;/ERROR/' test.log
  </code></pre>
  
  <p>and</p>
  
  <pre><code>awk -v d="$(date -d '1 day ago' +'%a %b %d %T %Z %Y')" '$1" "$2&gt;=d &amp;&amp;/ERROR/' test.log
  </code></pre>
  
  <p>with the same result.</p>
  
  <p>I need this to work without having to give it the exact date I'm searching for as it will be set up in cron to find the ERROR lines for the last 24 hours (or since midnight) and email the output to me.</p>
  
  <p>Thanks!</p>