第一类:数字性循环
-----------------------------
for1-1.sh
1 #!/bin/bash 2 3 for((i=1;i<=10;i++)); 4 do 5 echo $(expr $i \* 3 + 1); 6 done
-----------------------------
for1-2.sh
#!/bin/bash for i in $(seq 1 10) do echo $(expr $i \* 3 + 1);
-----------------------------
for1-3.sh
#!/bin/bash for i in {1..10} do echo $(expr $i \* 3 + 1); done
-----------------------------
for1-4.sh
#!/bin/bash awk 'BEGIN{for(i=1; i<=10; i++) print i}'
第二类:字符性循环
-----------------------------
for2-1.sh
#!/bin/bash list="rootfs usr data data2" for i in $list; do echo $i is appoint ; done
-----------------------------
for2-2.sh
#!/bin/bash for i in $* ; do echo $i is input chart\! ; done
-----------------------------
for2-3.sh
#!/bin/bash for i in f1 f2 f3 ; do echo $i is appoint ; done
-----------------------------
for2-4.sh
#!/bin/bash list="rootfs usr data data2" for i in $list; do echo $i is appoint ; done
第三类:路径查找
-----------------------------
for3-1.sh
#!/bin/bash for file in /proc/*; do echo $file is file path \! ; done
-----------------------------
for3-2.sh
#!/bin/bash for file in $(ls *.sh) do echo $file is file path \! ; done
作者:虚生 出处:https://www.cnblogs.com/dylancao/ 以音频和传感器算法为核心的智能可穿戴产品解决方案提供商 ,提供可穿戴智能软硬件解决方案的设计,开发和咨询服务。 勾搭热线:邮箱:1173496664@qq.com weixin:18019245820 市场技术对接群:347609188 |