echo -n "Enter a positive integer: "; read integer
While [ $integer -gt 0 ]; do
echo "$integer"
done
I am trying to write a script in UNIX that meets the following criteria:
- Name the script
while.sh. - Ask the user to enter a positive integer. You can assume that the user will enter a positive integer (input validation not required).
- Use a while loop to print all integers from 0 up to and including the integer entered.
The first two steps were easy, but I cannot get the third step to execute properly. Can anyone help me?
exprto increment a variable:x=`expr $x + 1`exprfor integer arithmetic; use the POSIX arithmetic expression;x=$((x + 1)).