title: Gnuplot; iterating over files in directory to print png
body: <p>In the directory l250 I have a couple of files. They each start off with "l2_" the part after it is the numerical value. I want to be able to plot what is in the file last.sh for about 300 files. I want to know what will be the way I can iterate over the file and have that be $1 and have the second value be $2. </p>
  
  <p>I was thinking that because the files are in the current directory I can use for. But then I am reading about awk and csv and I don't know what to do. I would like insight on what will be the better way to iterate over a large amount of files rater then putting it in main.sh and running that. </p>
  
  <p>main.sh</p>
  
  <pre><code>sh last.sh l2_4 1
  sh last.sh l2_5 2
  sh last.sh l2_6 3
  sh last.sh l2_7 4
  .
  .
  .
  </code></pre>
  
  <p>last.sh</p>
  
  <pre><code>gnuplot &lt;&lt; EOF
  set terminal png
  set output "finished/$1.png"
  set xlabel "Angs"
  set ylabel "Angs"
  set title "$1  |  $2 fs "
  set zrange [0: 0.00001]
  set pm3d map
  splot "$1"
  EOF
  </code></pre>
  
  <p>I run the following in the command line:    </p>
  
  <pre><code>$sh main.sh
  </code></pre>