0
我想問一下Bash和Sh中的命令。 在Cshell(.csh),我使用的標籤和命令 「GOTO」 爲:Bash和Sh上的標籤的哪個命令
#!/bin/csh -f
set a = 1
goto CHECK
CONT:
echo "${a}"
exit
CHECK:
if (${a} == 3) then
exit
else
goto CONT
endif
我使2標籤CONT
和CHECK
分離代碼行。 其他示例:
while (${lp_ct} < ${loop})
START_ROUND:
set count = 1
echo "===================================================="
bjobs | grep PEND | sort
echo "----------------------------------------------------"
echo "-- Round ${lp_ct}/${loop}"
set pend_s = `bjobs | grep PEND | grep -wc AL_Vcs_s`
if (${pend_s} > 4) then
echo "You are pending more than 4 license on AL_Vcs_s"
goto WAIT
endif
foreach job_pend (`bjobs | grep PEND | sort -r | awk '{print $1}'`)
bswitch AL_Vcs_s $job_pend
if (${count} == ${no_sw}) then
goto WAIT
else
@ count = ${count} + 1
goto SWITCH
endif
WAIT:
echo "-- Round ${lp_ct}/${loop} finished!"
echo "-- AL_Vcs PEND/TOTAL: `bjobs|grep PEND|grep -wc AL_Vcs`/`bjobs -u all|grep PEND|grep AL_Vcs -wc`"
echo "-- AL_Vcs_s PEND/TOTAL: `bjobs|grep PEND|grep -wc AL_Vcs_s`/`bjobs -u all|grep PEND|grep AL_Vcs_s -wc`"
@ lp_ct = ${lp_ct} + 1
goto END_ROUND
SWITCH:
end
END_ROUND:
sleep 6m
end
有任何命令可以在Bash和Sh上執行此任務嗎?
非常感謝。
看到這個:http://stackoverflow.com/questions/9639103/is-there-a-goto-statement-in-bash – codeforester