简单的几个shell脚本六
来源:互联网 发布:飞升元神数据 编辑:程序博客网 时间:2024/05/21 07:02
1、添加100个用户
#/bin/bash
#
if [ $# -lt 1 ];then
echo "Usage:./7.sh --add|--del"
exit 7
fi
if [ "$1" == "--add" ];then
for I in {1..100};do
if id user$I &> /dev/null;then
echo "user$I exists."
else
useradd user$I
echo "user$I" |passwd --stdin &> /dev/null
echo "Add user$I finished."
fi
done
elif [ "$1" == "--del" ];then
for I in {1..100};do
if ! id user$I &> /dev/null;then
echo "No user$I"
else
userdel -r user$I
echo "user$I deleted."
fi
done
else
echo "Unknown ARG:[--add|--del]"
exit 8
fi
2、添加用户使用参数和帮助
#!/bin/bash
#
if [ "$1" == "--add" ];then
for I in `echo $2 |sed 's/,/ /g'`;do
if id $I &> /dev/null;then
echo "$I exists."
else
useradd $I
echo $I|passwd --stdin $I &> /dev/null
echo "add $I finshed."
fi
done
elif [ "$1" == "--del" ];then
for I in `echo $2|sed 's/,/ /g'`;do
if id $I &>/dev/null;then
userdel -r $I
echo "$I deleted."
else
echo "No user $I"
fi
done
elif [ "$1" == "--help" ];then
echo "Usage:adminuser2.sh --add USER1,USER2,... | --del USER1,USER2,... | --help"
else
echo "No options. you can: --help"
fi
3、组合测试示例
#/bin/bash
#
if [ "$1" == "q" -o "$1" == "Q" -o "$1" == "Quit" -o "$1" == "quit" ];then
echo "quiting..."
exit 4
else
echo "Unknow options."
exit 1
fi
- 简单的几个shell脚本六
- 几个简单的shell脚本
- shell初学---几个简单的shell脚本
- 几个 简单的shell 脚本 借鉴一下
- 简单的几个shell脚本一
- 简单的几个shell脚本二
- 简单的几个shell脚本三
- 简单的几个shell脚本四
- 简单的几个shell脚本五
- 简单的几个shell脚本七
- 简单的几个shell脚本八
- 几个常用的shell脚本
- 几个不错的Shell脚本
- 几个不错的Shell脚本
- shell脚本的几个实例
- 几个常用的shell脚本
- linux 几个简单shell脚本demo
- 简单的shell脚本
- matlab代码批量屏蔽与取消屏蔽
- 陈怡暖:金价周一受耶伦讲话及美元走强影响
- js实现hash
- 粘滞广播--076集
- Spring MVC过滤器-登录过滤处理 ,访问页面的权限以及是否登陆
- 简单的几个shell脚本六
- HTML5 Canvas刮刮卡效果 实例
- 对XML文件的解析
- 软件版本GA,RC,alpha,beta,Build 含义
- Apk文件破解可见源码
- Duplicate methods named spliterator with the parameters () and () are inherited from the types Colle
- GitHub Android 开源项目汇总
- Tomcat6.0 SSL的配置
- objc_runtime给类目添加属性关联(objc_setAssociatedObject、objc_getAssociatedObject)