一.使用for循环语句
1.使用脚本添加用户
[root@centos ~]# vim /root/users.txt //用做测试的列表
[root@centos ~]# vim uaddfor.sh
[root@centos ~]# chmod +x uaddfor.sh
[root@centos ~]# ./uaddfor.sh
2.删除uaddfor.sh脚本所添加的用户
[root@centos ~]# vim udelfor.sh
二.使用while 循环语句
1.批量添加规律编号的用户
[root@centos ~]# vim uaddwhile.sh
[root@centos ~]# chmod +x uaddwhile.sh
[root@centos ~]# ./uaddwhile.sh
[root@centos ~]# grep “stu” /etc/passwd | tail -3
2.删除添加的用户
[root@centos ~]# vim udelwhile.sh
[root@centos ~]# chown +x udelwhile.sh
[root@centos ~]# ./udelwhile.sh
三.Case分支语句
1.检查用户输入的字符类型
[root@centos ~]# vim hitkey.sh
[root@centos ~]# chmod +x hitkey.sh
2.编写系统服务脚本
[root@centos ~]# vim myprop.sh
[root@centos ~]# chmod +x myprop
[root@centos ~]# ./myprop.sh start
正在启动sleep服务 …OK