撇嘴看天空

导航

2019年6月13日

linux 自动检查ssh脚本

摘要: check_ssh.sh #!/bin/bash #*/5 * * * * /home/check_ssh.sh process_day=`date -d today +"%Y-%m-%d %H:%M"` process=`ps -ef | grep -v 'grep' | grep "\<sshd 阅读全文

posted @ 2019-06-13 19:32 撇嘴看天空 阅读(267) 评论(0) 推荐(0)

删除linux访问记录(message删不了)

摘要: deljil.sh ckmsce=/home/deljl.exp aa=root bb=123456 omplist=" 192.168.1.14 192.168.1.15 192.168.1.16 192.168.1.17 192.168.1.18 192.168.1.19 192.168.1.2 阅读全文

posted @ 2019-06-13 19:28 撇嘴看天空 阅读(293) 评论(0) 推荐(0)

h3c 备份脚本

摘要: #!/bin/bash#0 0 1,10,22 * * /it_data3/h3c_backup.sh & #添加到计划任务 datetime=`date +%Y%m%d` BAKTIME=`date +%Y%m%d%H%M%S` user="admin" password="123456" bac 阅读全文

posted @ 2019-06-13 19:23 撇嘴看天空 阅读(177) 评论(0) 推荐(0)

linux 批量scp 脚本

摘要: scp.sh #!/bin/ship_list=/home/tools/scp/iplistsrc_file=/home/probecheck.shdest_file=/home/username=rootpassword=123456cat $ip_list | while read linedo 阅读全文

posted @ 2019-06-13 19:20 撇嘴看天空 阅读(442) 评论(0) 推荐(0)

Linux 删除几天前的文件脚本

摘要: #!/bin/bash filePath=/it_data2/ filePath1=/it_data3/cd $filePath ls filename1* -lrt --time-style="+%Y-%m-%d %H:%M %z" | awk '{print $6,$7,$9;}' | whil 阅读全文

posted @ 2019-06-13 19:17 撇嘴看天空 阅读(250) 评论(0) 推荐(0)

博达交换机镜像检查,镜像丢失自动添加脚本

摘要: check_bd_mirr.sh #!/bin/bash #/home/tools/check_tools/cfg_bd_mirror/check_bd_mirr.sh #所在目录文件名process_day=`date -d today +"%Y-%m-%d %H:%M:%S"` cd /home 阅读全文

posted @ 2019-06-13 19:12 撇嘴看天空 阅读(326) 评论(0) 推荐(0)

linux 批量升级openssh8.0

摘要: updateopenssh.sh explujing=/home/updateopenssh.exp username=root password=123456 iplist="192.167.1.94192.167.1.95192.167.1.96192.167.1.97" port=22 for 阅读全文

posted @ 2019-06-13 19:06 撇嘴看天空 阅读(343) 评论(0) 推荐(0)

linux 批量关闭telnet

摘要: shutdown_telnet.sh explujing=/home/shutdown_telnet.exp username=root password=123456 iplist="192.167.1.1 192.167.1.2 " port=22 for ip in $iplist do $e 阅读全文

posted @ 2019-06-13 19:00 撇嘴看天空 阅读(187) 评论(0) 推荐(0)

linux 批量安装telnet脚本

摘要: install_telnet.sh explujing=/home/install_telnet.exp username=root passwd=123456 iplist="192.167.1.1192.167.1.2192.167.1.3 " port=23 for ip in $iplist 阅读全文

posted @ 2019-06-13 18:55 撇嘴看天空 阅读(272) 评论(0) 推荐(0)

批量添加linux 定时任务crontab -e

摘要: 脚本如下 crontab_add.sh explujing=/home/crontab_add.exp username=rootpassword=123456 iplist="192.168.3.101 192.168.3.102"port=22for ip in $iplistdo $explu 阅读全文

posted @ 2019-06-13 18:47 撇嘴看天空 阅读(1178) 评论(0) 推荐(0)

linux 实现excel vlookup

摘要: 脚本内容 vlookup.sh #!/bin/bashawk 'NR==FNR{a[$1]=$0;next}NR>FNR{if($1 in a)print $0"\t"a[$1]}' $1 $2 >vlookup_result [root@localhost/home/]#cat aa1 a e2 阅读全文

posted @ 2019-06-13 18:00 撇嘴看天空 阅读(1872) 评论(0) 推荐(0)

Shell脚本编程

摘要: shell脚本 Shell脚本编程 1shell脚本--简介 1.1格式要求:首行shebang(sharp bang)<==>#!机制 ​ #!/bin/bash(用于shell脚本) ​ #!/usr/bin/python(用于python脚本) ​ #!/usr/bin/perl(用于perl 阅读全文

posted @ 2019-06-13 16:14 撇嘴看天空 阅读(322) 评论(0) 推荐(0)

SHELL脚本--数学运算和bc命令

摘要: 使用let、(())、$(())或$[]进行基本的整数运算,使用bc进行高级的运算,包括小数运算。其中expr命令也能进行整数运算,还能判断参数是否为整数,具体用法见expr命令全解。 其中let和(())几乎完全等价,除了做数学运算,还支持数学表达式判断,例如数值变量a是否等于3:let a==3 阅读全文

posted @ 2019-06-13 16:11 撇嘴看天空 阅读(1330) 评论(0) 推荐(0)

SHELL脚本--read命令

摘要: 1.1 shell read简介 要与Linux交互,脚本获取键盘输入的结果是必不可少的,read可以读取键盘输入的字符。 shell作为一门语言,自然也具有读数据的功能,read就是按行从文件(或标准输入或给定文件描述符)中读取数据的最佳选择。当使用管道、重定向方式组合命令时感觉达不到自己的需求时 阅读全文

posted @ 2019-06-13 16:11 撇嘴看天空 阅读(17529) 评论(1) 推荐(1)

Linux中使用 if 、for、while等循环来写脚本

摘要: 这次来介绍一下Shell的基本语法: 一、注释 Shell中的注释标志是井号 "#",除了脚本文件第一行的#不是注释之外,其他地方出现#,则说明#开始,到本行的末尾都是注释 二、指定脚本解释器 一般每个Shell脚本文件的第一行都是指定脚本解释器 #!/bin/bash : 指定本脚本文件使用bas 阅读全文

posted @ 2019-06-13 16:03 撇嘴看天空 阅读(1345) 评论(0) 推荐(0)

linux for 循环

摘要: 循环结构(for)for 变量名 in 列表do? 循环体done列表生成方式:(1) 直接给出列表(2) 整数列表:? (a) {start..end}? (b) $(seq [start [step]] end)(3) 返回列表的命令? $(COMMAND)(4) 使用glob,如:*.sh(5 阅读全文

posted @ 2019-06-13 15:58 撇嘴看天空 阅读(1661) 评论(0) 推荐(0)

linux shell case

摘要: 条件结构(case)case 变量引用 in PAT1) 分支1;; PAT2) 分支2;; ... *) ;; esaccase支持glob风格的通配符:? *: 任意长度任意字符? ?: 任意单个字符? []:指定范围内的任意单个字符? a|b: a或b9.2.1小试牛刀-case实例#模拟系统 阅读全文

posted @ 2019-06-13 15:53 撇嘴看天空 阅读(129) 评论(0) 推荐(0)

linux shell脚本 if eles

摘要: 条件结构(if)if 判断条件;then 条件为真的分支代码fi一切都以返回状态码是否为0为判决条件。如果执行结果的退出状态码为0,执行,不然就执行else部分小试牛刀-if-else实例#交互式判断年龄大于50为old man,小于等于50位young man#!/bin/bashread -p 阅读全文

posted @ 2019-06-13 15:51 撇嘴看天空 阅读(312) 评论(0) 推荐(0)

tr 压缩命令

摘要: tr: tr [options] [SET1] [SET2] 处理输入信息的(转换和删除字符串的,后换前); 默认是键盘输入,所以你输入tr,跟cat同理,都是等待键盘的输入的;所以tr和cat也可能利用<(输入重定向来)来接收文件的信息; 参数: -t:截断,使得SET1的长度和SET2的长度相同 阅读全文

posted @ 2019-06-13 15:48 撇嘴看天空 阅读(662) 评论(0) 推荐(0)

杀掉死循环脚本

摘要: ps auxf|grep '脚本名'|grep -v grep|awk '{print $2}'|xargs kill -9 阅读全文

posted @ 2019-06-13 15:45 撇嘴看天空 阅读(152) 评论(0) 推荐(0)

spwan expect 转义字符

摘要: " 对应 \" ' 对应 \' [] 对应 \[\] \ 对应 \\\ $ 对应\\\$ 阅读全文

posted @ 2019-06-13 15:44 撇嘴看天空 阅读(298) 评论(0) 推荐(0)

批量修改linux终端命令提示符设置(PS1)记录

摘要: 首先安装软件包 expect-5.44.1.15-4.el6.x86_64.rpm tcl-8.5.13-8.el7.x86_64.rpm tcl-devel-8.5.13-8.el7.x86_64.rpm 执行bashrc.sh脚本 bashrc.sh调用bashrc.exp bashrc.sh 阅读全文

posted @ 2019-06-13 15:41 撇嘴看天空 阅读(227) 评论(0) 推荐(0)

sed awk sort uniq grep seq

摘要: 1.显示主机名: cat /etc/sysconfig/network |grep HOSTNAME | awk -F "=" '{print $2}' 2.显示文件行数:wc -l file 3.file1先排序再去重保存到file2:cat file1 | sort | uniq >file2 阅读全文

posted @ 2019-06-13 15:33 撇嘴看天空 阅读(223) 评论(0) 推荐(0)

shell 脚本时间引用

摘要: 反引号:`` 反引号里面的内容是命令行,通过反引号用户可以将shell命令的输出赋给变量,比如: #!/bin/bashtest=`date +%y%m%d` process_day1=`date -d today +"%Y-%m-%d %H:%M:%S"` process_day2=`date - 阅读全文

posted @ 2019-06-13 15:08 撇嘴看天空 阅读(216) 评论(0) 推荐(0)

文件描述符

摘要: 文件描述符缩写描述0 STDIN 标准输入1 STDOUT 标准输出2 STDERR 标准错误 2>&1 >file:错误输出到终端,标准输出被重定向到文件file中。>file 2>&1:标准输出被重定向到文件file,然后错误输出也重定向到和标准输出一样,也是输出到文件file中>file 2> 阅读全文

posted @ 2019-06-13 15:04 撇嘴看天空 阅读(139) 评论(0) 推荐(0)

linux 删除目录下几天之前指定文件(或目录)

摘要: find /data1/filename*/ -name "cdr_idx_*" -mtime +1 -exec rm -f {} \; 脚本 #!/bin/bashm=70dbkeep=95dbpercent=`df -h | grep data | grep sd | awk -F ' ' '{ 阅读全文

posted @ 2019-06-13 15:03 撇嘴看天空 阅读(2927) 评论(0) 推荐(0)