title: "awk fatal cannot open file for reading (no such file or directory)" in for loop in bash script
body: <p>I made a Bash script with an AWK script to read files with network pings and then calculate the parameters that the TCP protocol gets like timeout and estimatedRTT.</p>
  
  <p>I inserted it in a for loop to read all the files in a folder, but it throws the error of unable to read. Here is the code:</p>
  
  <pre><code>for f in *.txt
  do awk '
  function abs(v) {return v &lt; 0 ? -v : v}
  
  BEGIN {
     alpha=0.125;
     beta=0.25;
  }
  
  FNR == 1 {
      sampleRTT=$1;
      estimatedRTT=SampleRTT;
      devRTT=0.0000;
      timeoutInterval=EstimatedRTT;
      printf("%f\t%f\t%f\n", sampleRTT, estimatedRTT, timeoutInterval)}
  
  FNR &gt; 1{
      sampleRTT=$1
      estimatedRTT=((1-alpha)*estimatedRTT)+(alpha*sampleRTT);
      devRTT=((1-beta)*devRTT)+(beta*(abs(sampleRTT-estimatedRTT)));
      timeoutInterval=estimatedRTT+(4*devRTT);
      printf("%f\t%f\t%f\n", sampleRTT, estimatedRTT, timeoutInterval)}' %f
  done
  </code></pre>
  
  <p>I tried using $f, '$f' and "$f". none works. Just works reading single files at once. I didn't delete the files nor I run the script in another folder.</p>