#!/bin/ksh
######### FOR #################
for i in HUP INT QUIT TERM
do
echo $i
done
#cat f.txt
#aa ab
#ba bb bc
#
#!/bin/ksh
for word in `cat f.txt`
do
echo $word
done
######### WHILE #################
BEGIN=1
END=10
IDX=$BEGIN
while [ $IDX -ge $BEGIN -a $IDX -le $END ]
do
echo $IDX
IDX=$((IDX + 1))
done
while $expr
do
...
done
while (true)
do
...
done
while read i X
do
echo $i $X
done < f.txt
ls -1s *.out | sort | while read X table_file
do
...
done
# Execute all the ttSize() built-in procedures
$X10_BIN/ttIsql -connStr dsn=tt41data <<-EOF | grep "^< " | cut -d' ' -f2 | cut -d'.' -f1 | while read SIZE
$SQL
exit
EOF
do
# Add the size of each table to totSize
((totSize = totSize + SIZE))
done
continue #continue next for variable
break #break from loop
Unix Shell - Loop statement
最新推荐文章于 2025-11-18 09:39:00 发布
本文详细介绍了Shell脚本中for循环、while循环的使用方法及示例,包括基本语法、条件判断、文件读取等应用场景,并展示了如何通过continue和break控制循环流程。

1610

被折叠的 条评论
为什么被折叠?



