This is a test version of Biostars. For the public version, visit https://www.biostars.org.
For loop - mkdir and command

Hi all. I am trying to write a for loop in bash. The goal is to create a directory with the same name of the input file for the command and use it as output folder for the same command. I came up with this:

for i in *.fasta; do mkdir /Users/laura/bio/insilicoseq/$i; iss generate --draft /Users/laura/bio/Assemblies/fasta/*.fasta --model miseq --output /Users/laura/bio/insilicoseq/${i} --cpus 8 --n_reads 1267000; done

the directory is created but the iss generate command saves the output in the 'insilicoseq' folder.

Could anyone help me please?

Thanks,
Laura

bash

1 answer

Perhaps:

for F in *.fasta; do 
    mkdir /Users/laura/bio/insilicoseq/$(basename "$F" .fasta)
    iss generate \
        --draft "$F" \
        --model miseq \
        --output /Users/laura/bio/insilicoseq/$(basename "$F" .fasta) \
        --cpus 8 \
        --n_reads 1267000
done

Log in to answer this question.