Mastering Shell Scripting: Loops, User Input, and Practical Applications
1. Looping in Shell Scripts
Looping is a fundamental aspect of programming, and the Bash shell offers several commands for creating loops in scripts.
1.1 The if - then and continue Command
The if - then statement combined with the continue command can control the flow of loops. For example:
if [ $a -gt 2 ] && [ $a -lt 4 ]
then
continue 2
fi
This code stops processing the commands inside the loop but continues the outer loop. In the script output, when $a is 3, the inner loop statements are skipped, and the outer loop continues.
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



