我想问一下Bash和Sh中的命令。 在Cshell(.csh)上,我使用label和命令“goto”:
#!/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上有任何命令可以执行此任务吗?
非常感谢你。
答案 0 :(得分:0)
似乎Bash没有goto或相同的指令。你应该试试功能,我想