Bash 4.0 increment variable

Hi there everyone!

This is my first post so be gentle.

I have a small bash script that is extracting 3 line every 3 lines. I got the AWK part but i cant do the loop part.

#!/bin/bash
export line=`awk 'END { print NR }' btnew`
echo $line

for i in {1..$line..3} #increment
do 
echo " "
awk "NR==$i,NR==$i+2" btnew #print  line n until n+2
echo " "
done

For some reason passing the total sum of lines ($line) to the increment wont work.
Any ideas?

Ouput:

9
 
awk: NR=={1..9..3},NR=={1..9..3}+2
awk:     ^ syntax error
awk: NR=={1..9..3},NR=={1..9..3}+2
awk:          ^ syntax error
awk: NR=={1..9..3},NR=={1..9..3}+2
awk:              ^ syntax error
awk: NR=={1..9..3},NR=={1..9..3}+2
awk:                        ^ syntax error

for (( i=1; i<=$line; i=i+3 ))

If you're extracting 3 lines every 3 lines, isn't it as good as extracting all the lines? Please post a sample input, desired output and the logic that goes into processing the input to arrive at the output.

Thank you balajesuri,this did the work!

 for (( i=1; i<=$line; i=i+3 ))