title: Bash send mail only if file contains string
body: <p>A process creates a new log file each time it runs. If the log file contains the string ERROR, I want it to be emailed to me using mail. I do not want an email if there were no errors.</p>
  
  <p>Created alias named admins in .mailrc for recipients</p>
  
  <p>This command works fine to always send the log via email:</p>
  
  <pre><code>cat /home/user/import.log | mail -s 'Import Error Log' admins
  </code></pre>
  
  <p>Now then what I want is a concatenated command to check if the file contains 'ERROR' then run the mail command only if it does.</p>
  
  <p>Thanks in advance.</p>