随笔分类 - shell脚本
摘要:https://www.jb51.net/article/186134.htm for 命令: for i in 的各种用法 : for i in “file1” “file2” “file3” for i in /boot/* for i in /etc/*.conf for i in $(seq
阅读全文
摘要:function check_elb_icp(){ cat ${net_name}_iplist_elb.txt | while read ipline; do vm_name=`echo $ipline |awk -F',' '{print $1}'` ip=`echo $ipline |awk
阅读全文
摘要:mysql -h10.184.206.116 -uimsfz -pImsfz@hj2020 -D imsfz -e "source /imsfz/imsfz/imsfz-hj/sxx_mysql/silentnumber_sql.sql" mysql -h地址 -u账号 -p密码 -D 数据库 -e
阅读全文
摘要:http://c.biancheng.net/linux/sleep.html 先让程序睡上 30 秒 从字面意思看,想必你已经猜出来 sleep 命令的作用啦。简单地说,sleep 就是让程序稍稍休息一下,然后,再继续工作(休息是为了更好地工作……)。我们让 Shell 程序小憩 30 秒: #睡
阅读全文
摘要:https://blog.csdn.net/weixin_39980360/article/details/116617483 【截取】 一、Linux shell 截取字符变量的前8位,有方法如下: 1.expr substr “$a” 1 8 2.echo $a|awk ‘{print subs
阅读全文
摘要:https://blog.csdn.net/u010670689/article/details/45077177 在指定的日期上减去指定的天 [dc@dc010.tj.momo.com init_env]$ date -d "20150416 12 3 days" +"%Y%m%d%H" 2015
阅读全文
摘要:##第五个字段以186开头,打印出整行 cat * | awk -F'|' '{if ($5 ~/^186/) {print $0}}'| sort | uniq ##根据某列去重 [root@localhost cc]# cat 2.txt adc 3 5 a d a a 3 adf a d b
阅读全文
摘要:条件表达式 文件表达式 if [ -f file ] 如果文件存在 if [ -d ... ] 如果目录存在 if [ -s file ] 如果文件存在且非空 if [ -r file ] 如果文件存在且可读 if [ -w file ] 如果文件存在且可写 if [ -x file ] 如果文件存
阅读全文
摘要:#!/bin/bash#A:S pro_file=${1} file_day=$(date "+%Y%m%d%H") #comd="chown sms:sms /utxt/soft/scmd/scmd" #comd="echo '* * * * * root sh /utxt/soft/script
阅读全文
摘要:#!/bin/bash#A:S pro_file=${1} file_day=$(date "+%Y%m%d%H") comd="cat /etc/crontab " restart_fun(){ cat ${pro_file}.txt | while read ipline; do ip=`ech
阅读全文
摘要:for (( j=2;j<4;j++ )) do #echo ${barringtype[$j]} ${listtype[$j]} if [[ $barry1 = ${barringtype[$j]} ]] && [[ $list1 = ${listtype[$j]} ]]; then let mo
阅读全文
摘要:if [[ $barry1 = ${barringtype[$j]} ]] && [[ $list1 = ${listtype[$j]} ]]; then let mod++ fi
阅读全文
摘要:/usr/bin/expect << EOF spawn /usr/bin/ssh -t -p 22088 -oStrictHostKeyChecking=no sms@${ip} "su " expect { "*assword*" { send "Eastcom@!@#\n" } } expec
阅读全文
摘要:#!/bin/bash build_dir="build" if [ ! -d "$build_dir" ];then mkdir $build_dir fi
阅读全文
摘要:/usr/local/bin/redis-cli -h redishost -a redispass command > /dev/null 2>&1 redishost :redis主机信息 redispass :redis密码 command :查询命令 > /dev/null 2>&1 :忽略
阅读全文
摘要:function check(){ expect -c " spawn ssh -A -q -\oStrictHostKeyChecking=no user@IP -t \" sudo timeout 2s sh test.sh \" expect { \"*assword\" { send \"p
阅读全文