简单shell脚本,安装、上传、查询日志

1、安装:yum -y install lrzsz      

lrzsz:代替ftp上传和下载的程序,centos 和 redhat支持该命令

2、上传.sh格式:Rz 

3、脚本

#!/bin/bash
echo "-------------------start------------------------"
read -p "enter ip:" ip
read -p "enter key_word:" key_word

cat logs/${ip}/*.out | grep -n -C10 ${key_word} | tail -20
cat logs/${ip}/*.out | grep -n -C10 ${key_word} | tail -20 >tmp.log

echo "-------------------Find Finished-----------------"

4、执行

a、Sh  xxx.sh;

b、1)Chmod 777  xxx.sh;

2)./xxx.sh

原文地址:https://www.cnblogs.com/mobies/p/11645925.html