文章分类 -  shell知识

摘要:#!/usr/bin/expect set timeout 10 set username [lindex $argv 0] set password [lindex $argv 1] set hostname [lindex $argv 2] spawn ssh-copy-id -i /root/ 阅读全文
posted @ 2018-02-27 11:28 reborn枪 阅读(88) 评论(0) 推荐(0)
摘要:全网备份 校验 阅读全文
posted @ 2017-09-25 09:49 reborn枪 阅读(114) 评论(0) 推荐(0)
摘要:取消敏感的历史记录 阅读全文
posted @ 2017-09-21 10:30 reborn枪 阅读(154) 评论(0) 推荐(0)
摘要:定时任务 给监控服务弄个复活甲 定时任务 阅读全文
posted @ 2017-05-08 13:50 reborn枪 阅读(132) 评论(0) 推荐(0)
摘要:if 阅读全文
posted @ 2017-05-01 11:07 reborn枪 阅读(122) 评论(0) 推荐(0)
摘要:#man test -n STRING the length of STRING is nonzero STRING equivalent to -n STRING -z STRING the length of STRING is zero STRING1 = STRING2 the string 阅读全文
posted @ 2017-03-07 11:01 reborn枪 阅读(296) 评论(0) 推荐(0)
摘要:-z,! -z与-n的分别 系统脚本示例: 阅读全文
posted @ 2017-03-07 10:25 reborn枪 阅读(464) 评论(0) 推荐(0)
摘要:[root@web02-7 scripts]# echo `echo {1..10}|tr " " "+"`=`echo {1..10}|tr " " "+"|bc` 1+2+3+4+5+6+7+8+9+10=55 [root@web02-7 scripts]# echo `seq -s "+" "10"`=`seq -s "+" "10"|bc` 1+2+3+4+5+6+7+8+9+10=55... 阅读全文
posted @ 2017-02-27 16:05 reborn枪 阅读(273) 评论(0) 推荐(0)
摘要:[root@web02-7 scripts]# time for i in $(seq 11111);do count=${#chars};done; real 0m0.187s user 0m0.090s sys 0m0.002s [root@web02-7 scripts]# time for i in $(seq 11111);do count=`echo ${chars}|wc -L`... 阅读全文
posted @ 2017-02-27 15:03 reborn枪 阅读(111) 评论(0) 推荐(0)
摘要:[root@web02-7 scripts]# which ssh-copy-id/usr/bin/ssh-copy-id 阅读全文
posted @ 2017-02-27 14:41 reborn枪 阅读(216) 评论(0) 推荐(0)
摘要:[root@web02-7 scripts]# abc="ni hao zhong guo ren" [root@web02-7 scripts]# echo ${#abc} #第一种 20 [root@web02-7 scripts]# echo $abc|wc -L #第二种 20 ... 阅读全文
posted @ 2017-02-27 14:34 reborn枪 阅读(150) 评论(0) 推荐(0)
摘要:[root@web02-7 scripts]# cat calc.sh #!/bin/bash [ $# -ne 2 ] && { echo "you must input tow num:$0 arg1 arg2" exit 1 } expr $1 + 0 &>/dev/null [ $? -eq 0 ] ||{ echo "you must input $1 rigth nu... 阅读全文
posted @ 2017-02-27 10:53 reborn枪 阅读(267) 评论(0) 推荐(0)
摘要:[root@rsync-41 ~]# result=${test:-UNSET} [root@rsync-41 ~]# echo $result UNSET [root@rsync-41 ~]# test="abc" [root@rsync-41 ~]# echo $result UNSET [root@rsync-41 ~]# result=${test:-UNSET} #通知 [roo... 阅读全文
posted @ 2017-02-26 22:28 reborn枪 阅读(246) 评论(0) 推荐(0)
摘要:[root@rsync-41 ~]# cat /etc/init.d/rpcbind #! /bin/sh # # rpcbind Start/Stop RPCbind # # chkconfig: 2345 13 87 # description: The rpcbind utility is a server that converts RPC program \ # ... 阅读全文
posted @ 2017-02-26 21:53 reborn枪 阅读(762) 评论(0) 推荐(0)
摘要:[root@rsync-41 ~]# set -- "i am" successful xusx #通过set设置参数 [root@rsync-41 ~]# echo $1 i am [root@rsync-41 ~]# echo $2 successful [root@rsync-41 ~]# echo $3 xusx [root@rsync-41 ~]# echo $@ i a... 阅读全文
posted @ 2017-02-24 20:53 reborn枪 阅读(100) 评论(0) 推荐(0)
摘要:[root@web02-7 ~]# cat /server/scripts/dir_base.sh #!/bin/bash dirname $0 basename $0 [root@web02-7 ~]# sh /server/scripts/dir_base.sh /server/scripts dir_base.sh [root@web02-7 scripts]# ec... 阅读全文
posted @ 2017-02-22 18:05 reborn枪 阅读(96) 评论(0) 推荐(0)
摘要:$0:获取当前执行的Shell脚本的文件名,如果执行脚本包含了路径,那么就包括脚本路径 $n:获取当前执行的Shell脚本的第n个参数值,n=1..9,当n=0时表示脚本的文件名。当n大于9,需要大括号,${10} $#:获取当前执行的Shell脚本后面接的参数的总个数 $*:获取当前执行的Shel 阅读全文
posted @ 2017-02-22 11:08 reborn枪 阅读(184) 评论(0) 推荐(0)
摘要:123 阅读全文
posted @ 2017-02-22 10:41 reborn枪 阅读(186) 评论(0) 推荐(0)
摘要:1、环境变量(全局变量) 3个命令显示变量值:set、env、declare env declare set -o 2、普通变量(局部变量) 在登录Linux系统并启动一个bash shell时,默认情况下bash会在若干个文件中查找环境变量的设置。这些文件可统称为系统环境文件。bash检查的环境变 阅读全文
posted @ 2017-02-21 13:53 reborn枪 阅读(210) 评论(0) 推荐(0)