for 变量 in 循环; do
statement
done
练习:
写一个脚本计算1到100的所有整数合
#!/bin/bash
#
declare -i SUM=0
for I in {1..100};
do
let SUM=$[$SUM+$I]
done
echo "The sum is $SUM“
时间: 2024-12-18 00:24:50
for 变量 in 循环; do
statement
done
练习:
写一个脚本计算1到100的所有整数合
#!/bin/bash
#
declare -i SUM=0
for I in {1..100};
do
let SUM=$[$SUM+$I]
done
echo "The sum is $SUM“