loops - Bash Script accepting a number, then printing a set of int from 0 to the number entered -
i trying write bash script accepts number keyboard, , prints set of integers 0 number entered. can't figure out how @ all. code:
while [ 1 ] echo -n "enter color: " read user_answer (( $user_answer = $user_answer; $user_answer>0; $user_answer--)) echo $user_answer fi done exit
the error i'm recieving is: number_loop: line 10: syntax error near unexpected token echo' number_loop: line 10:
echo $user_answer'
assign separate variable in order use increment/decrement operators. $user_answer=$user_answer
true , throw error when trying use decrement. try following :
#!/bin/bash while [ 1 ] echo -n "enter color: " read user_answer (( i=$user_answer; i>0; i-- )) echo $i done done exit
Comments
Post a Comment