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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -