I did a bash script for running a program (Velveth) that takes as input all Fasta files (.fa) in a directory, and give the results in a new directory.
#!/bin/bash
for filename in /home/lpp/Desktop/test/*.fa; do
velveth outdirectory 21 -fasta -short "$filename"
done
I can loop throw all fasta files but each iteration rewrites the result in the same folder. How could I rename for each iteration the output directory?
I tried giving the same name as the file:
#!/bin/bash
for filename in /home/lpp/Desktop/test/*.fa; do
velveth "$filename" 21 -fasta -short "$filename"
done
but it does not work.
thanks.
What I would recomment you to do is create the directoy before using it as output and also not create directory with the same names as the files. If you want to put the output in the same directory as the file, I would recommend doing this:
#!/bin/bash
for filename in /home/lpp/Desktop/test/*.fa; do
mkdir ${filename%.*}
velveth ${filename%.*} 21 -fasta -short "$filename"
done
${filename%.*}
will remove the suffix of the file, thus making foo
out of foo.fa
, that way you wont create directory with the exact same name as the file... creating directory foo
for the file foo.fa
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments