Why wont this code run?
It is meant to allow the user to input a number into the script in a loop until the user enters a -1 then the script should terminate
However I keep getting this error:
-ne: unexpected operator
Here is the code:
#!/bin/sh
condition= 0
while [ $condition -ne -1 ]
do
echo $condition
read condition
done
You have to remove the space after the
condition=and the0. As spaces are the natural token separator of bash, you have to be very careful where you put spaces. In this case, the space separates a list of initialized variables (in this case with an empty value) of the supposed program (0).