title: How can I find the names of log files with 'error' on the last line?
body: <p>I am trying to find the id's of jobs that end in error.</p>
  
  <p>When I use</p>
  
  <pre><code>for i in *log
  do tail -n 1 $i | grep error
  echo $i
  done
  </code></pre>
  
  <p>It seems to find error on the last line of each file, even for files that don't have errors on the last line, and returns all of the filenames with</p>
  
  <pre><code>STOP fatal_error
  out1.log
  STOP fatal_error
  out2.log
  STOP fatal_error
  out3.log
  ....
  </code></pre>
  
  <p>even though </p>
  
  <pre><code>grep error out1.log 
  </code></pre>
  
  <p>returns nothing</p>
  
  <p>Alternatively, is there an easier way to get a list of the jobs that end in error? I tagged with qsub because I use qsub to submit the jobs  </p>