title: Passing a shell variable to awk in gnuplot
body: <p>I need to pass a shell variable to awk in gnuplot but I get error messages :
  The variable is set in the sript and is called FILE. This changes according to date.
  My code : (in a Gnuplot script)</p>
  
  <pre><code>plot FILE using 1:14 with points pointtype 7 pointsize 1 # this works fine
  
  replot '&lt; awk ''{y1 = y2; y2 = $14; if (NR &gt; 1 &amp;&amp; y2 - y1 &gt;= 100) printf("\n") ; if (NR &gt; 1 &amp;&amp; y2 -y1 &lt;= -100) printf("\n"); print}'' FILE' using 1:14 with linespoints 
  Err msg
  awk: fatal: cannot open file `FILE' for reading (No such file or directory)
  </code></pre>
  
  <p>When I hard code the FILE path the replot works.</p>
  
  <p>Could anyone clarify the code I need to pass this variable to awk? Am I on the right track with something like :</p>
  
  <pre><code>% environment_variable=FILE
  % awk -vawk_variable="${environment_variable}" 'BEGIN { print awk_variable }' ?
  </code></pre>
  
  <p>Here is my Gnuplot script code: cobbled together from other posts mostly..</p>
  
  <pre><code>#FILE selection - we want to plot the most recent data file
  
  FILE = strftime('/data/%Y-%m-%d.txt', time(0))  # this is correct
  
  print "FILE is : " .FILE
  
  #set file path variable for awk :      (This is where my problem is)
  
  awk -v var="$FILE" '{print var}'
  
  awk '{print $0}' &lt;&lt;&lt; "$FILE"
  </code></pre>
  
  <p>Thank you in advance</p>