SHELL训练营--day20_shell练习41-45
发布时间:2020-12-15 23:02:53 所属栏目:安全 来源:网络整理
导读:#问候脚本 #!/bin/bash d=`date +%H` if [ $d -ge 0 -a $d -lt 7 ] then tag=1 elif [ $d -ge 7 -a $d -lt 12 ] then tag=2 elif [ $d -ge 12 -a $d -lt 18 ] then tag=3 else tag=4 fi case $tag in 1) echo "早上好" ;; 2) echo "上午好" ;; 3) echo "下午
#问候脚本 #!/bin/bash d=`date +%H` if [ $d -ge 0 -a $d -lt 7 ] then tag=1 elif [ $d -ge 7 -a $d -lt 12 ] then tag=2 elif [ $d -ge 12 -a $d -lt 18 ] then tag=3 else tag=4 fi case $tag in 1) echo "早上好" ;; 2) echo "上午好" ;; 3) echo "下午好" ;; 4) echo "晚上好" ;; esac #菜单脚本 #!/bin/bash echo -e "1) wn2) lsn3) pwdn4) quit" while do read -p "Please input your choice(1-4):" c case $c in 1) w ;; 2) ls ;; 3) pwd ;; 4) exit ;; *) echo "Please input 1-4." ;; esac done #检查用户登录 #!/bin/bash while : do if w|sed ‘1‘d|awk ‘{print $1}‘|grep -qw "$1" then echo "$1 用户已经登录。" fi sleep 300 done #检查系统是否被*** #!/bin/bash pp=$$ ps -elf|sed ‘1‘d > /tmp/pid.txt for pid in `awk -v ppn=$pp ‘$5!=ppn {print $4}‘ /tmp/pid.txt` do if ! [ -d /proc/$pid ] then echo "系统中没有pid为$pid的目录。请检查。" fi done #三行合一行 #!/bin/bash n=1 cat $1|while read line do n1=$[$n%3] if [ $n1 -eq 0 ] then echo "$line" else echo -n "$line " fi n=$[$n+1] done
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- angularjs – Angular2 GA / Final Release中ControlGroup和
- yum安装时提示No package xxx available,解决办法
- Vim 高阶用法
- unix – 为什么umask是一个AND NOT掩码操作
- 如何开始使用bootstrap
- 边缘 – 如何在Bootstrap 3网格系统中调整沟槽?
- vim:关联扩展与语言
- angularjs – Identity Server身份验证,无需请求用户权限
- angularjs – 如何在另一个服务中从外部文件注入服务的模拟
- CXF Webservice 6 - Spring 3 整合Apache CXF WebService