Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 意外';其他';语法错误_Bash_Variables - Fatal编程技术网

Bash 意外';其他';语法错误

Bash 意外';其他';语法错误,bash,variables,Bash,Variables,运行脚本时,出现以下错误: 意外的“else”语法错误 我觉得一切都很好 #!/bin/bash # # if [$#>1] then perl blockingsessionsprojse.pl $1 else perl blockingsessionsprojse.pl 300 fi 您的代码中有2个错误。首先,如果关键字错误,则使用 $ help if if: if COMMANDS; then COMMANDS; [ elif COMMANDS;

运行脚本时,出现以下错误:

意外的“else”语法错误

我觉得一切都很好

#!/bin/bash
#
#
if [$#>1] then
        perl blockingsessionsprojse.pl $1
else
        perl blockingsessionsprojse.pl 300
fi

您的代码中有2个错误。首先,如果关键字错误,则使用

$ help if
if: if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMMANDS; ] fi
注意
。因此,它应该是:

if [$#>1]; then
if [ $# -gt 1 ]; then
其次,您需要在
[
之后和
]
之前添加一个空格,并在
运算符周围添加一个空格(在进行数值比较时需要是
-gt
),因此如果
条件应为:

if [$#>1]; then
if [ $# -gt 1 ]; then

您的代码中有2个错误。首先,如果关键字错误,则使用

$ help if
if: if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMMANDS; ] fi
注意
。因此,它应该是:

if [$#>1]; then
if [ $# -gt 1 ]; then
其次,您需要在
[
之后和
]
之前添加一个空格,并在
运算符周围添加一个空格(在进行数值比较时需要是
-gt
),因此如果
条件应为:

if [$#>1]; then
if [ $# -gt 1 ]; then
尝试:

尝试: