There are four things in your script that you should consider changing. Two of them are syntax related:
- Assignments can not have spaces around
=. You have this error in two places. - To do an arithmetic less than or equal test, use
-lt, not<=. The<=is an input redirection from a file called=.
The other two are:
- Always double quote expansion. Use
echo "$n"orprintf '%s\n' "$n"instead ofecho $n. Use[ "$n" -lt 99 ]instead of[ $n -lt 99 ]. In the general case, the shell would otherwise split the variable's value into words and apply filename globbing rules to each of those words. - You don't need
declare -ihere. Declaring a variable as integer inbashis very rarely needed.
See also:
- When is double-quoting necessary?
- The https://www.shellcheck.net/ web site is useful for checking shell script syntax.