title: Bash script to to subtract values from corresponding lines contained in variables
body: <p>I don't think this has been asked: I have been working on a small bash script to pull down some data and my idea was to have it compare today's data from yesterday's to find usage. </p>
  
  <p><code>Today</code>'s file looks like:</p>
  
  <pre><code>150
  100
  50
  </code></pre>
  
  <p><code>Yesterday</code>'s file looks like:</p>
  
  <pre><code>145
  99
  20
  </code></pre>
  
  <p>I am looking for something that will subtract line1 from <code>Today</code> from <code>Yesterday</code> <em>when the contents of both files are stored in variables of the same name</em> and print out the result. </p>
  
  <pre><code>Total
  5
  1
  30
  </code></pre>
  
  <p>From the command line with files, it works, but from the script, which reads the contents of variables holding the data, it prints out the first <code>cat</code> and then can't find the file:</p>
  
  <pre><code>cat file1 | awk '{n=$0; getline &lt; "file2"; print" " n-$0}'
  5
  1
  30
  WORKS
  
  cat $Today | awk '{n=$0; getline &lt; "$Yesterday"; print" " n-$0}'
  cat: 5: No such file or directory
  cat: 1: No such file or directory
  cat: 30: No such file or directory
  </code></pre>
  
  <p>Any idea?</p>