I have a file (file_in.txt
) containing these names:
aphid_splitseq.1.fasta.annot.xml
aphid_splitseq.2.fasta.annot.xml
aphid_splitseq.3.fasta.ann
As long as both your lists are just repetitions of the same kind of name with successive numbers, you shouldn't iterate over files at all. Instead, just count a variable and use that in whatever command you want executed at each step. Example:
COUNT=1
while [ $COUNT -lt 5 ]; do
mv inputfile$COUNT outputfile$COUNT
let COUNT++
done
paste
can be helpful:
#!/bin/bash
paste file_in.txt file_out.txt | while read if of; do
echo "-in $if -out $of"
done
yields:
-in aphid_splitseq.1.fasta.annot.xml -out aphid_splitseq_1
-in aphid_splitseq.2.fasta.annot.xml -out aphid_splitseq_2
-in aphid_splitseq.3.fasta.annot.xml -out aphid_splitseq_3
-in aphid_splitseq.4.fasta.annot.xml -out aphid_splitseq_4
-in aphid_splitseq.5.fasta.annot.xml -out aphid_splitseq_5
you can modify this to get the desired behaviour.
Use While
While read line
do
line=$(echo -ne $line | sed or awk)
done < Directory/filename.t