a simple while loop

Hallo everyone

I might just be being dumb, but I am using the BASH shell and cannot get the following script to work:

x=0
while [ $x -lt 10 ]
do
echo $x
x=�echo "$x + 1" | bc�
done

Can anybody help me out. I am just get a repeating output saying:
bc: command not found
0 + 1: command not found

Any suggestions would be helpful :confused:

x=`echo "$x + 1" | bc`

... backticks ....

You could also use

x=$((x+1))

Also can use let

x=0
while [ $x -lt 10 ]
do
echo $x
let x=x+1
done

bash also has the for loop constuct

for (( x=0 ; x<10 ; x++ )) 
do 
    echo $x
done

Thanks guys!

You have been a real help :slight_smile: