How can I Run one script on multiple files and print out multiple files.
FOR EXAMPLE
i want to run script.pl on 100 files named 1.txt ....100.txt under same directory and print out corresponding file 1.gff ....100.gff.THANKS
You haven't specified how your script works. Here is an example based on the assumption that your script is called script.sh and writes output to standard output
#script foo.sh, calls your script "script.sh" and assumes that #script.sh writes to standard output
while read a
do
filename=`echo ${a} | cut -d\. -f1`
echo ${filename}
./script.sh ${a} > ${filename}.gff
done
Then you do...
ls [1-9].txt | ./foo.sh
I want to do
perl genome.gff 1.txt > 1.gff
there are multiple files for 1.txt; 1_1.txt.....3_4.txt,
how can i generate 1_1.gff......corespondingly? Thank you
Replace
./script.sh ${a} > ${filename}.gff
with
perl genome.gff ${a} > ${filename}.gff
Try
for FN in *.txt
do perl genome.gff "$FN" > "${FN%.*}".gff
done