0

Hey guys I am trying to teach myself shell scripting, but I am stuck in a error and I am just unsure how to fix it. I have created a simple while loop that should just give a output from 0-9. This is the error I receive

./loops.sh: line 10: 0: command not found ./loops.sh: line 11: [: -lt:unary operator expected

Here is my code

#while loop
x= 0
while [ $x -lt 10 ]
do
        echo $x
        x= 'expr $x + 1'
done
Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
  • In addition to the two duplicates, an alternative to something like `x=$(expr "$x" + 1)` would be `((++x))` (when using Bash). – Benjamin W. Jun 25 '21 at 23:40
  • In case it is not obvious to you from the linked questions: You are using single quotes (`'`) which are the wrong quote characters for command substitution. – Michael Jaros Jun 26 '21 at 00:11

0 Answers0