for-loopc.sh
来自「一本完整的描述Unix Shell 编程的工具书的所有范例」· Shell 代码 · 共 39 行
SH
39 行
#!/bin/bash# Two ways to count up to 10.echo# Standard syntax.for a in 1 2 3 4 5 6 7 8 9 10do echo -n "$a "done echo; echo# +==========================================+# Now, let's do the same, using C-like syntax.LIMIT=10for ((a=1; a <= LIMIT ; a++)) # Double parentheses, and "LIMIT" with no "$".do echo -n "$a "done # A construct borrowed from 'ksh93'.echo; echo# +=========================================================================+# Let's use the C "comma operator" to increment two variables simultaneously.for ((a=1, b=1; a <= LIMIT ; a++, b++)) # The comma chains together operations.do echo -n "$a-$b "doneecho; echoexit 0
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?