Hello I'm trying to run bowtie for a several files using a loop so I don't have to repeat the command over and over. The loop looks something like this:
mm10="GenomeFolder/Bowtie2Index/genome"
for (( i = 76; i <= 79; i++ ))
do
bowtie2 -x $mm10 -1 SRR51363$i_1.fastq.gz -2 SRR51363$i_2.fastq.gz \
done
The problem is that I can't use the $i variable in between SRR51363 and _1.fastq.gz, It causes an error. Any adivce on the right syntax? I tried to google this but it's hard to describe this problem I'm having. Thank you!
Put curly braces around variable names, and quotes around words:
mm10="GenomeFolder/Bowtie2Index/genome"
for (( i = 76; i <= 79; i++ ))
do
bowtie2 -x "${mm10}" -1 "SRR51363${i}_1.fastq.gz" -2 "SRR51363${i}_2.fastq.gz"
done
Curly braces in this context prevent variable names from being expanded incorrectly. Quotes allow files and paths to contain spaces and special characters. While the latter may not be an issue here for this specific example, it is a good habit to get into.