-1

I am getting a syntax error in the following code. I am trying to print the squares of a number n.

#!/bin/sh

echo "Enter a number n to print squares : "
read num

i=1

while [ $i -le $num ]
do

    echo $(expr $i * $i)
    i=$(expr $i + 1)

done

echo "Done with Script"

Can someone tell me whats wrong with the code? Thank you guys in advance.

tripleee
  • 175,061
  • 34
  • 275
  • 318

1 Answers1

0
#!/bin/sh

echo "Enter a number n to print squares : "
read num

i=1

while [ $i -le $num ]
do

    echo $(expr $i \* $i)
    i=$(expr $i + 1)

done

echo "Done with Script"

Shield * symbol.

Viktor Khilin
  • 1,760
  • 9
  • 21