title: Using diff for two files and send by email
body: <p>I have files like below. I use crontab every 5 min to check the files to see if the system's added one file, for example like this: <code>AIR_2015xxxxT0yyyyyyyy.cfg</code>. Then I need to use the <code>diff</code> command automatically between the last one and before the last one.</p>
  
  <pre><code>AIR_20151021T163514000.cfg
  AIR_20151026T103845000.cfg
  AIR_2015xxxxT0yyyyyyyy.cfg
  </code></pre>
  
  <p>I want to do this in a script like the one below:</p>
  
  <pre><code>#!/bin/bash
  /var/opt/fds/
  diff AIR_2015xxxxT0yyyyyyyy.cfg AIR_20151026T103845000.cfg &gt; Test.txt
  
  body(){
  cat body.txt
  }
  (echo -e "$(body)") | -a Test.txt mailx -s 'Comparison' user@email.com
  </code></pre>