Bash script error: [i: command not found

后端 未结 4 1504
面向向阳花
面向向阳花 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 19:00

    Like the others have said, the [ program needs a space before its parameters, like all programs need a space before their args. This is one reason why I prefer the test builtin to [ with its kludgy syntax requiring a useless ] as the last arg just to make it look pretty and sane.

    if test $((i % j)) = 0; then
       break
    fi
    

提交回复
热议问题