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-10-21 10:02:49 1792548169 0.009265