title: capture last line of file as integer variable and use in awk command
body: <p>I am trying to capture the last line of a file as a variable for use in an awk command.</p>
  <p>Here is an example of the file (the end of it) :</p>
  <pre><code>cat file.txt 
  ....
   phylum:Chlorophyta 1
   phylum:Mucoromycota 1
  column 6:
   superkingdom:Eukaryota 99
  column 7:
   
   99
  </code></pre>
  <p>I want to use that '99' as an integer in an awk command, saving it as a variable,</p>
  <pre><code>tail -n1 file.txt
  99 
  </code></pre>
  <p>e.g.</p>
  <pre><code>div=$(tail -n1 file.txt)
  
  echo $div
  99
  </code></pre>
  <p>To be used in a 2nd file (conf.txt), to divide the numbers in the 2nd field:</p>
  <pre><code>cat conf.txt
  Class 88
  Family 78
  Genus 44
  Species 23
  </code></pre>
  <p>BUT, when I try to use the <code>$div</code> variable in the awk command (using <code>-v</code> flag as suggested here and elsewhere with awk when taking a variable) I get this error:</p>
  <pre><code>awk -v a=$div '{print $2/a}' conf.txt 
  awk: can't open file {print $2/a}
   source line number 1
  
  
  </code></pre>
  <p>But when saivng 99 as a variable simply on the cmd line,  It works just fine:</p>
  <pre><code>num=99
  awk -v a=$num '{print $2/a}' conf.txt 
  0.888889
  0.787879
  0.444444
  0.232323
  </code></pre>
  <p>Are there extra spaces/characters in the capture from <code>tail -1</code>? I am missing something simple, but fundamental.</p>
  <p>Ultimatey, I don't even want to have to save as a separate variable first If I dont have to, instead, just capture that last line number (99) and put directly into an awk cmd, e.g.:</p>
  <pre><code>awk  '{print $2/[tail -1 file.txt]}' conf.txt 
  
  </code></pre>
  <p>This is psuedo code (in the brackets)  ...but, this would ultimately be what Id want...</p>
  <p>Thanks for any help!</p>