shell脚本
2019-09-07 15:35
1201 查看
1打印九九乘法口诀表
for i in `seq 9` ;do for j in `seq 9` ;do if [ $i -ge $j ];then let sum=${i}*${j} echo -e "${i}x${j}=$sum\t\c" fi done echo done
2.检查磁盘空间,一旦发现任何分区利用率高于80%,就发出警报
disk=`fdisk -l | egrep -o "^/dev/[[:alpha:]]+[0-9]"` #disk=`lsblk | sed -rn "s/^├─([[:alpha:]]{3}[1-9]).*/\1/p"` max_num=0 for name in `echo $disk`;do #有可能是交换空间,df命令就没有显示。直接跳过 if ! df | egrep -o "^$name.*" &> /dev/null;then continue fi #获取使用空间和inodes num=`df | egrep -o "$name.*" | tr -s " " "%" | cut -d "%" -f 5` Inodes_num=`df -i | egrep -o "$name.*" | tr -s " " "%" | cut -d "%" -f 5` #使用空间和inodes大于80就发出警告。 if [ $num -ge 80 -o $Inodes_num -ge 80 ];then if [ $num -gt $max_num ];then max_num=$num max_name=$name max_Inodes_num=$Inodes_num elif [ $num -eq $max_num ];then max_equal_num=$num max_equal_name=$name max_equal_Inodes_num=$Inodes_num fi fi done #判断是否有超过80的 if [ $max_num -ne 0 ];then let remaining=100-$max_num let Inodes_remaining=100-$max_Inodes_num #判断是否有两个分区使用量一样 if [ -z $max_equal_num ];then wall The $max_name disk is about to run out, Only the remaining disk is ${remaining}% and Inodes${Inodes_remaining}% else wall The $max_name and $max_equal_name disk is about to run out, Only the remaining disk is ${remaining}% and Inodes${Inodes_remaining}% fi fi
相关文章推荐
- shell脚本中的特定变量
- Shell脚本编程
- shell脚本的一些注意事项
- 【脚本】shell 中 continue 的用法
- 2011-06-15 shell脚本学习
- shell脚本的引用用法说明
- Shell脚本中调用另外一个脚本的方法
- 在shell脚本中使用函数的返回值
- Shell编程中的用户输入处理(3):在shell脚本中,处理命令行参数
- shell脚本中if的相关参数
- Shell脚本中单引号(‘)和双引号(“)的使用区别
- 能够匹配任意长度的回文字的shell脚本 match_palindrome.sh
- 关于shell脚本时遇value too great for base (error token is "08")
- shell 脚本 时间
- 常用的主机监控shell脚本
- shell 脚本调用java进程
- shell脚本打印日志方法
- 网卡流量监控脚本 ( Shell )
- Java调用shell脚本
- shell脚本判断进程是否存在,并重新启动