When I run this script I get this error:
./myscript.sh: 16: arithmetic expression: expecting primary: "1 ** 1"
When I run this shell script with bash, as in #! /bin/bash
on the first line, the math works properly; unfortunately I need to use /bin/sh
. What am I doing wrong? I'm on Linux Mint if that matters.
#! /bin/sh
x=1
while [ $x -le 10 ]
do
y=1
while [ $y -le 10 ]
do
echo $(($y ** $x))" \c"
y=`expr $y \+ 1`
done
echo
x=`expr $x \+ 1`
done