# 示例1
for i in `rpm -qa | grep ptyhon`; do echo $i; done for i in $(rpm -qa | grep python); do echo $i; done # 推荐
# 示例2
for i in {1,2,3}; do echo $i; done for i in host{1,2,3}; do echo $i; done for i in host{1..10}; do echo $i; done for i in host1 host2 host3; do echo $i; done
# 示例3
for ((i=1;i<=10;i++)); do echo $i; done
# 示例4,遍历数组
my_array = (A B C D) for i in ${my_array[@]}; do echo $i; done