试图理解给我的 Bash 脚本,特别是 while 循环
Trying to understand a Bash script given to me, specifically the while loop
我正在使用我的一位前同事制作的脚本,他告诉我我需要使用它。我想知道这个 while 循环是做什么的:
# This is the loop that does the simulation
lastsim=0
nextsim=`/usr/bin/expr $lastsim + 1`
while [ $nextsim -le $upperlimit ]
do
cp -i Dynamics_${lastsim}_500ps/*.prmtop ./$paramInput.prmtop
具体来说,我对 thie -le 语法感到困惑
这只是脚本的一部分,如果需要我可以上传其余部分。
-le
表示小于或等于。请参阅以下将打印 0-9 的示例:
i=0
while [ $i -le 9 ]; do
echo $i
let i++
done
我正在使用我的一位前同事制作的脚本,他告诉我我需要使用它。我想知道这个 while 循环是做什么的:
# This is the loop that does the simulation
lastsim=0
nextsim=`/usr/bin/expr $lastsim + 1`
while [ $nextsim -le $upperlimit ]
do
cp -i Dynamics_${lastsim}_500ps/*.prmtop ./$paramInput.prmtop
具体来说,我对 thie -le 语法感到困惑 这只是脚本的一部分,如果需要我可以上传其余部分。
-le
表示小于或等于。请参阅以下将打印 0-9 的示例:
i=0
while [ $i -le 9 ]; do
echo $i
let i++
done