一、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)
本文出自 “7995400” 博客,请务必保留此出处http://8005400.blog.51cto.com/7995400/1913194
原文:http://8005400.blog.51cto.com/7995400/1913194