一、for 死循环
for ((;;))
do
echo "hello world!"
sleep 1
done
二、for循环读取列表
list="a b c"
for i in ${list[*]}
do
echo $i
done
三、for循环条件判断
for ((i=0;i<3;i++))
do
echo "hello world;"
done
四、while 死循环
while true
do
echo "hello world!"
sleep 1
done
五、for循环读取文件
for line in `cat filename`
do
echo ${line}
done
六、while循环读取文件
# 第一种
while read line
do
echo $line
done < filename
# 第二种
cat filename | while read line
do
echo $line
done