LMLPHP后院

shell 条件语句 if then

先来看语法。

if statement

if command
then
  commands
fi

连写语法:

if command; then
  commands
fi

if else statement

if command
then
  commands
else
  commands
fi

if elif statement

if command_1
then
  commands

elif command_2
then
  commands

elif command_3
then
  commands

# ...

fi

条件语句中 command 执行成功,则会执行 then 中的 commands。

2026-01-23 08:36:06 1769128566 0.009025