摘要: #!/bin/bashecho "ping一个地址三次 看是否能够平通"read -ep "请输入要ping的地址" dz ping -c 3 $dz &> /dev/null if [ $? -eq 0 ] then echo “host $dz 能ping通” else echo "host $ 阅读全文
posted @ 2020-05-06 20:07 鸿杨杨 阅读(468) 评论(0) 推荐(0) 编辑
摘要: #!/bin/bashecho "判断是不是root用户,是的情况下继续执行"read -ep "请输入用户" yh if [ $yh = root ] then cd /root else echo "不是root用户,权限不够" fi 阅读全文
posted @ 2020-05-06 20:06 鸿杨杨 阅读(380) 评论(0) 推荐(0) 编辑
摘要: #!/bin/bashecho "查看目录是否存在,不存在则新建"read -ep "请输入" ml if [ ! -e $ml ] then mkdir -p $ml else echo "文件存在"fi 阅读全文
posted @ 2020-05-06 20:03 鸿杨杨 阅读(218) 评论(0) 推荐(0) 编辑
摘要: #!/bin/bashread -ep "请输入用户的数量:" slfor i in `seq $sl`do grep "user-$i" /etc/passwd > /dev/null if [ $? -ne 0 ] then useradd user-$i > /dev/null if [ $? 阅读全文
posted @ 2020-05-06 20:01 鸿杨杨 阅读(280) 评论(0) 推荐(0) 编辑
摘要: #!/bin/bashnumber=$[RANDOM%1000]while truedo for i in `seq 0 3` do if [ $i -eq 3 ] then read -ep "已经错了三次 是否继续?(yes/no):" d if test $d == "yes" then le 阅读全文
posted @ 2020-05-06 20:00 鸿杨杨 阅读(154) 评论(0) 推荐(0) 编辑
摘要: #!/bin/bashread -ep "请输入要创建的用户" yhgrep -w $yh /etc/passwdif [ $? -eq 0 ]then userdel -r $yh echo "用户存在,已删除" useradd $yh echo "用户新建成功"else useradd $yh 阅读全文
posted @ 2020-05-06 19:57 鸿杨杨 阅读(199) 评论(0) 推荐(0) 编辑
摘要: #!/bin/bashread -ep "请输入要创建的用户" yhgrep -w $yh /etc/passwdif [ $? -eq 0 ]then userdel -r $yh echo "用户存在,已删除" useradd $yh echo "用户新建成功"else useradd $yh 阅读全文
posted @ 2020-05-06 19:56 鸿杨杨 阅读(152) 评论(0) 推荐(0) 编辑
摘要: #!/bin/bashsum=0a=`seq 1 100`for i in $ado let sum=$i+sumdoneecho $sum 阅读全文
posted @ 2020-05-06 19:54 鸿杨杨 阅读(192) 评论(0) 推荐(0) 编辑
摘要: #!/bin/basha=`ls -l|awk -F ' ' '$5==0{print $9}'` for i in $a do rm $idone 阅读全文
posted @ 2020-05-06 19:53 鸿杨杨 阅读(192) 评论(0) 推荐(0) 编辑
摘要: #!/bin/basha=`seq 1 255`for i in $ado ping -c 1 192.168.10.$a if [ $? -eq 0 ] then echo "能ping通" else echo "ping不通" fidone 阅读全文
posted @ 2020-05-06 19:52 鸿杨杨 阅读(208) 评论(0) 推荐(0) 编辑