Bash script error: [i: command not found

后端 未结 4 1507
面向向阳花
面向向阳花 2021-01-22 18:03

This program is suppose to accept a number from the user and print that many prime numbers. For some reason the program doesn\'t work. I am new to bash scripting and this is my

4条回答
  •  春和景丽
    2021-01-22 18:46

    You need to place a space after the [ because [ is an application.

    And you can't make calculations between the brackets. You will need to tell bash it needs to calculate the values. So you would need to change line 11 to if (( i % j == 0 )).

提交回复
热议问题