2011-09-30

Shell循环

Views: 13419 | Add Comments

做个笔记:

SHELL循环:

1. while
i=0; while [ $i -lt 10 ]; do echo $i; i=$(($i+1)); done

2. for
for ((i=1; i<=10; i++)); do echo $i; done

3. while
cat file.txt | while read line; do echo $line; done
while read line; do echo $line; done < file.txt

Related posts:

  1. if-else对优化代码冗余度的反作用
  2. PHP浮点数显示和转成字符串
  3. WordPress分页代码
  4. Nginx + PHP 配置和启动脚本
  5. 用PHP去除重复图片文件
Posted by ideawu at 2011-09-30 12:14:11

Leave a Comment