Writing a loop to process multiple input files by a shell script

I have multiple input files that I want to manipulate using a shell script. The files are called 250.1 through 250.1000 but I only want the script to manipulate 250.300 through 250.1000. Before I was using the following script to manipulate the text files:

for i in 250.*; do
[ "$i" = 'X.txt' ] || awk 'NR==FNR{A[NR]=$6;next}{$6=A[FNR]}1' "$i" 'X.txt' > "X.${i%.txt}"
done

But the script above manipulates all scripts 1 through 1000 whereas I want it to specifically manipulate 300 through 1000. How can I change the script above to do that?

What's your system?

What's your shell?

You've already been given a perl solution, what was wrong with it?

My system is Ubuntu 11.04 and shell is bash, I believe.

Well that perl script worked but the output of the bash loop that I posted above was the input of the perl script. So I need to get this bash loop working first.

Can this work for you:

for i in 250.[3-9]* 250.1000; do 
  [ "$i" = 'X.txt' ] || awk 'NR==FNR{A[NR]=$6;next}{$6=A[FNR]}1' "$i" 'X.txt' > "X.${i%.txt}"
done

If you have BASH, you have for-loop:

for ((N=300; N<=1000; N++))
do
        FILENAME=250.$N

        ...
done

This would be better than for file in * since it's less likely to match other things by accident and isn't going to ever cram too many arguments for for to handle into anything.