第十一讲Shell编程主讲人:沈超()交流论坛:…do程序done#!/bin/bash#打印时间#Author:shenchao(E-mail:shenchao@lampbrother.net)fortimeinmorningnoonafternooneveningdoechoThistimeis$time!done#!/bin/bash#批量解压缩脚本#Author:shenchao(E-mail:shenchao@lampbrother.net)cd/lampls*.tar.gzls.logforiin$(catls.log)dotar-zxf$i&/dev/nulldonerm-rf/lamp/ls.log语法二for((初始值;循环控制条件;变量变化))do程序done#!/bin/bash#从1加到100#Author:shenchao(E-mail:shenchao@lampbrother.net)s=0for((i=1;i=100;i=i+1))dos=$(($s+$i))doneechoThesumof1+2+...+100is:$s#!/bin/bash#批量添加指定数量的用户#Author:shenchao(E-mail:shenchao@lampbrother.net)read-pPleaseinputusername:-t30nameread-pPleaseinputthenumberofusers:-t30numread-pPleaseinputthepasswordofusers:-t30passif[!-z$name-a!-z$num-a!-z$pass]theny=$(echo$num|sed's/[0-9]//g')if[-z$y]thenfor((i=1;i=$num;i=i+1))do/usr/sbin/useradd$name$i&/dev/nullecho$pass|/usr/bin/passwd--stdin$name$i&/dev/nulldonefifi