bun*_*nny 3 linux script bash shell
我有一个if
条件。如果该条件为真,则将运行一个脚本,然后我需要检查另一个条件。
我怎样才能使用if
语句或其他东西来做到这一点?
例如,
if [ condition -eq o ]
then
run script
again condition(this condition depends on above script output value)
run another script
else
exit
Run Code Online (Sandbox Code Playgroud)
您的代码需要具有以下结构:
if [condition -ne 0]
then
do_something
if [expression that depends on exit status of do_something]
then
do something_else
fi
fi
Run Code Online (Sandbox Code Playgroud)
句法
Run Code Online (Sandbox Code Playgroud)if test-commands; then consequent-commands; [elif more-test-commands; then more-consequents;] [else alternate-consequents;] fi
该
test-commands
执行列表中,如果它的返回状态是零,则consequent-commands
执行列表中。如果
test-commands
返回非零状态,则依次执行每个 elif 列表,如果其退出状态为零,more-consequents
则执行相应 的命令并完成命令。如果
else alternate-consequents
存在,并且最后一个 if 或 elif 子句中的最后一个命令具有非零退出状态,则alternate-consequents
执行。返回状态是最后执行的命令的退出状态,如果没有条件测试为真,则为零。
请参阅下面的示例链接。
归档时间: |
|
查看次数: |
5060 次 |
最近记录: |