随笔分类 -  Shell

Shell脚本实例
摘要:[root@izwz9hmoz58gvtu0ldpm0iz ~]# cat /usr/local/aaaa/shell_script/Mysql_Dump_LJY.sh #! /bin/bash today=`date +%Y%m%d%H` yesterday=`date -d "1 day ago" +%Y%m%d` work_dir="/usr/local/haha/database_ba... 阅读全文
posted @ 2017-11-07 19:15 Ray雷 阅读(194) 评论(0) 推荐(0)
摘要:在linux下,将top命令的结果保存到文本上 阅读全文
posted @ 2017-11-07 19:12 Ray雷 阅读(7024) 评论(0) 推荐(1)
摘要:1,写一个循环,ping整个子网的ip。 使用while循环 #!/bin/bash ip=223 while [ "$ip" -ne "239" ] do ping 121.201.0.$ip -c1 && echo "121.201.0.$ip yes" >> ip_list.txt || ec 阅读全文
posted @ 2017-08-01 12:03 Ray雷 阅读(249) 评论(0) 推荐(0)
摘要:vi auto_ssh.exp #!/usr/bin/expect set ipaddress "123.227.159.159" set passwd "你的密码" set timeout 30 spawn ssh root@$ipaddress expect { "yes/no" {send " 阅读全文
posted @ 2017-08-01 11:55 Ray雷 阅读(271) 评论(0) 推荐(0)
摘要:1. IF条件判断语法: if Athen dosthelif B dosthelse dosthfi 2. 判断条件: 2.1 字符串判断 str1 = str2 当两个串有相同内容、长度时为真 str1 != str2 当串str1和str2不等时为真 -n str1 当串的长度大于0时为真(串 阅读全文
posted @ 2017-05-11 10:52 Ray雷 阅读(476) 评论(0) 推荐(0)
摘要:一、逻辑运算符 二、逻辑表达式 test 命令 使用方法:test EXPRESSION 如: [root@localhost ~]# test 1 = 1 && echo 'ok'ok [root@localhost ~]# test -d /etc/ && echo 'ok' ok [root@ 阅读全文
posted @ 2017-05-11 10:51 Ray雷 阅读(551) 评论(0) 推荐(0)
摘要:# ping一个IP,延时大于5,输出延时大于5s,打印输出 #!/bin/bash ip=$* echo $ip num=`ping -c 10 ${ip}|grep icmp_seq|awk '{print $7}'|cut -d= -f2` for snum in $num do if [ ` 阅读全文
posted @ 2017-05-11 10:50 Ray雷 阅读(1168) 评论(0) 推荐(0)