how to set file as a variable in bash -
i new in bash scripting set files variables in loop in bash script. have code:
a=home/my_directory/*.fasta b=home/my_directory/*.aln in {1..14} # have 14 files in my_directory file extension .fasta clustalo -i $a -o $b # clustalo command of clustal omega software, -i # input file, -o output file done
i want use fasta files in my_directory , create 14 new aln files. code doesnt work because clustal program doesnt recognize set files. if can thankful.
if know there 14 files, this:
for in {1..14}; clustalo -i home/my_directory/$a.fasta -o home/my_directory/$b.aln done
if want process of *.fasta
files, many there are, do:
for file in home/my_directory/*.fasta; clustalo -i "$file" -o "${file%.fasta}.aln" done
to understand this, ${file%.fasta}
gives $file
.fasta
extension stripped off.
if want store file names in variable first, best thing use array variable. adding parentheses around variable assignment, , accessing array values strange syntax "${array[@]}"
.
files=(home/my_directory/*.fasta) file in "${files[@]}"; clustalo -i "$file" -o "${file%.fasta}.aln" done
Comments
Post a Comment