问题就在你根本不会shell的基本语法就想当然瞎写
代码:
if list; then list; [ elif list; then list; ] ... [ else list; ] fi
The if list is executed. If its exit status is zero, the then list is executed. Otherwise, each elif list is executed
in turn, and if its exit status is zero, the corresponding then list is executed and the command completes. Otherwise,
the else list is executed, if present. The exit status is the exit status of the last command executed, or zero if no
condition tested true.
代码:
[[ expression ]]
Return a status of 0 or 1 depending on the evaluation of the conditional expression expression. Expressions are composed
of the primaries described below under CONDITIONAL EXPRESSIONS. Word splitting and pathname expansion are not performed
on the words between the [[ and ]]; tilde expansion, parameter and variable expansion, arithmetic expansion, command sub‐
stitution, process substitution, and quote removal are performed. Conditional operators such as -f must be unquoted to
be recognized as primaries.
代码:
test expr
[ expr ]
Return a status of 0 (true) or 1 (false) depending on the evaluation of the conditional expression expr. Each operator
and operand must be a separate argument. Expressions are composed of the primaries described above under CONDITIONAL
EXPRESSIONS. test does not accept any options, nor does it accept and ignore an argument of -- as signifying the end of
options.