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?