问轩博客

展开菜单

Shell批量分发脚本

Shell批量分发脚本
[root@m01 /]# cat fenfa.sh  #!/bin/sh . /etc/init.d/functions if [ $# -ne 2 ] then     echo "usage:$0 localfile remotedir"   &nbs...

用sshpass批量实现基于key验证

用sshpass批量实现基于key验证
[root@shnne ~]# cat ssh-pass.sh  #!/bin/bash #利用sshpass批量实现基于key验证 #author by Jean DIR=`cd $(dirname $0);pwd` FILE=$DIR/pass.txt #生成key ssh-keygen -f /root/.ssh/id_rsa  ...

判断一组数字按连续数字分段并输出结果

判断一组数字按连续数字分段并输出结果
[www@shnnejudgenum]$ cat judgenum.sh  #!/bin/bash #by Jean #判断一组数字按连续数字分段并输出结果 #原理:用for循环从1开始过滤,按顺序过滤一个就不换行打印当前数字和空格,如果过滤不到,就换行打印空,直到再次过滤到继续打印 #然后排除空行,用awk取第一列和最后一列,这样就可以得到一组数字的按顺序分段了 Dir=$(cd `dirname ...

监测网站目录是否有篡改

监测网站目录是否有篡改
方法一:md5sum [root@shnne scripts]# cat diffpro.sh  #!/bin/sh path=/server/scripts/cuangai [ ! -d $path ] && mkdir -p $path  [ ! -f $path/diff.log...

打印下面不大于6的单词

打印下面不大于6的单词
[root@shnne ~]# cat liu.log  I am shnne welcome to my blog. [root@shnne ~]# cat liu.sh  #!/bin/sh array=($(cat liu.log)) for((i=0;i<${#array[@]};i++)) do...

监测MySQL主从同步shell脚本

监测MySQL主从同步shell脚本
1. [root@shnne ~]# cat slave_check.sh  #!/bin/sh while true do flag=0  array=($(egrep "_Running|Behind_Master" slave.log|awk '{print $NF}'))    for&nb...

continue,break,exit小例子

continue,break,exit小例子
[root@shnne ~]# vim test.sh #!/bin/sh for ((i=0; i<=5; i++)) do    if [ $i -eq 3 ]     then        #contin...

shell批量修改文件名方法

shell批量修改文件名方法
1. 创建 [root@shnne ~]# cat mk.sh  #!/bin/sh for((i=1; i<=10; i++)) do   j=`cat /dev/urandom|head -1|md5sum|cut -c 1-5`   touch shnne/${j}_shnne_$i.html don...

for小练习

for小练习
通过for循环打印5 4 3 2 1[root@shnne ~]# cat for1.sh  #!/bin/sh for i in 5 4 3 2 1 do   echo $i done   [root@shnne ~]# cat for2.sh  #!/bin/sh f...

while计算小练习

while计算小练习
[root@shnne ~]# cat sum_* #!/bin/sh sum=0 i=1 while [ $i -le 100 ] do   let sum=sum+i   let i=i+1 done echo $sum #!/bin/sh sum=0 i=1 while ((i&...

shell编写rsync启动脚本

shell编写rsync启动脚本
[root@shnne ~]# cat rsync_start.sh  #!/bin/bash # chkconfig: 2345 58 80 # description: start and stop service for rsync . /etc/init.d/functions RSYNCBIN=&q...