0

I'm trying to make a bash script to run hisat2 program, but 'No such file or directory' error occurs.

Here is my script.

#!/usr/bin bash

File='abc.txt'
Samples=$(cat $File)
IDX=/mnt/g/refs/wheat/iwgsc_refseqv2.1_assembly.fa
WD=/mnt/g/translocation

for Sample in $Samples
do
    "hisat2 -x $IDX -p 16 -1 $WD/"$Sample"_R1.fastq.gz -2 $WD/"$Sample"_R2.fastq.gz | samtools sort > $WD/$Sample.bam"
done

The outcome is enter image description here

, which seems correct. It runs OK when I just copy and paste the code in a terminal.

I'm looking forward to any advices. Thank you.


Thank you! It worked without "". However, I have another problem. The program worked out but a result file was not created.

#!/usr/bin bash

File='abc.txt'
Samples=$(cat $File)
IDX=/mnt/g/refs/wheat/iwgsc_refseqv2.1_assembly.fa
WD=/mnt/g/translocation

for Sample in $Samples
do
    hisat2 -x $IDX -p 16 -1 $WD/"$Sample"_R1.fastq.gz -2 $WD/"$Sample"_R2.fastq.gz | samtools sort > $WD/$Sample.bam
done

Is my code something wrong?

Woojoo
  • 11
  • 1
  • 1
    It's because you have double quotes around the entire line, so it's expecting a program called `"hisat2 -x ..."` not a program called `"hisat2"`. – Stephen Quan May 10 '22 at 04:27
  • Copy and paste the command to the terminal including the double quotes and you will get the same error message. Actually, the error message which you posted in your scrrenshot already tells you what's going wrong. – user1934428 May 10 '22 at 05:43

0 Answers0