text: user13885: I am attempting to edit my fastq sequence files with an awk command from a published article. The sequence files are all contained in one directory where I am running the awk command from the terminal in a Linux environment. There are 4 fastq files in the directory
  01_thu159_IX_RNA_001.fastq
  01_thu163_IX_RNA_001.fastq
  01_thu164_IX_RNA_001.fastq
  01_thu190_IX_RNA_001.fastq
  
  I would like to trim all these files at once with the awk command so I wrote this for loop:
  for filename in ./*.fastq*
  do
  awk -v s=10 -v e= 40 ' {if (NR%2 == 0) print substr ($0, s+1, length ($0)-s-e); else print $0;} ' ./${filename} >  ./${filename}_trimmed
  done
  
  However, I am getting the following error:
  awk: fatal: cannot open file ` {if (NR%2 == 0) print substr ($0, s+1, length ($0)-s-e); else print $0;} ' for reading (No such file or directory)
  
  I then thought maybe it was an error with the for loop so I tried the command as per the instructions in the article
  awk -v s=10 -v e= 40 '{if (NR%2 == 0) print substr ($0, s+1, length ($0)-s-e); else print $0;}' ./01_thu159_IX_RNA_001.fastq > ./Trim_01_thu159_IX_RNA_001.fastq
  
  But this also produced the same error:
  awk: fatal: cannot open file `{if (NR%2 == 0) print substr ($0, s+1, length ($0)-s-e); else print $0;}' for reading (No such file or directory)
  
  I have checked the syntax for the awk command and it should be correct. Could anyone please give me advice as to what I am doing wrong and how to fix this issue?
  
  user14015: You have a whitespace here:
  e= 40
  
  awk thinks that 40 is your rule and the rest of the line is a filename.
  
original_text: 13885: <p>I am attempting to edit my <code>fastq</code> sequence files with an <code>awk</code> command from a published article. The sequence files are all contained in one directory where I am running the <code>awk</code> command from the terminal in a Linux environment. There are 4 fastq files in the directory</p>
  <pre><code>01_thu159_IX_RNA_001.fastq
  01_thu163_IX_RNA_001.fastq
  01_thu164_IX_RNA_001.fastq
  01_thu190_IX_RNA_001.fastq
  </code></pre>
  <p>I would like to trim all these files at once with the <code>awk</code> command so I wrote this <code>for</code> loop:</p>
  <pre><code>for filename in ./*.fastq*
  do
  awk -v s=10 -v e= 40 ' {if (NR%2 == 0) print substr (<span class="math-container">$0, s+1, length ($</span>0)-s-e); else print <span class="math-container">$0;} ' ./$</span>{filename} &gt;  ./${filename}_trimmed
  done
  </code></pre>
  <p>However, I am getting the following error:</p>
  <pre><code>awk: fatal: cannot open file ` {if (NR%2 == 0) print substr (<span class="math-container">$0, s+1, length ($</span>0)-s-e); else print $0;} ' for reading (No such file or directory)
  </code></pre>
  <p>I then thought maybe it was an error with the <code>for</code> loop so I tried the command as per the instructions in the article</p>
  <pre><code>awk -v s=10 -v e= 40 '{if (NR%2 == 0) print substr (<span class="math-container">$0, s+1, length ($</span>0)-s-e); else print $0;}' ./01_thu159_IX_RNA_001.fastq &gt; ./Trim_01_thu159_IX_RNA_001.fastq
  </code></pre>
  <p>But this also produced the same error:</p>
  <pre><code>awk: fatal: cannot open file `{if (NR%2 == 0) print substr (<span class="math-container">$0, s+1, length ($</span>0)-s-e); else print $0;}' for reading (No such file or directory)
  </code></pre>
  <p>I have checked the syntax for the <code>awk</code> command and it should be correct. Could anyone please give me advice as to what I am doing wrong and how to fix this issue?</p>
   14015: <p>You have a whitespace here:</p>
  <pre><code>e= 40
  </code></pre>
  <p>awk thinks that 40 is your rule and the rest of the line is a filename.</p>
  