一、while语句
declare -i i=0
declare -i sum=0
while [ ${i} != 100 ]
do
i=$((${i}+1))
# echo "i=${i}"
sum=$((${sum}+${i}))
done
echo "${sum}"
二、for语句
mypath=/etc/passwd
myusers=$(cat ${mypath} | awk -F":" ‘{print $1}‘)
for users in ${myusers}
do
id ${users}
done
exit 0
三、for语句
for nethost in $(seq $2 $3)
时间: 2024-10-16 06:08:21