欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

shell实现提取字符串某个字符,压缩文件,并上传到服务器

程序员文章站 2022-03-10 22:08:56
...
#!/bin/bash

keyword="SYSTEM_NAME"
confname="/tmp/reliabilityEcosystem.conf"
datapath="/database/"
sniffpath="/enggdata/SnifferLogs"
currenttime=$(date "+%y%m%d%H%M%S")
filename="cell${cellnum}_snifferlog_$currenttime.tar.gz"

### 1,get the cell num
cellnum=$(grep $keyword $confname | cut -d '=' -f2 | cut -b 6-)
echo "1,$cellnum--------------------"
### 2,tar snifferlog
cd $datapath
#tar -zcvf $filename  $sniffpath/*
echo "2,----------------------------"
ls $datapath
echo "tar successfully!"
### 3,upload the snifferlog to the server
scp $filename [email protected]:/media/xrayreli/logs/EverestG3/G3SYS${cellnum}/
echo "snifferlog has been uploaded to the server!"
### 4,rm the snifferlog 
cd $sniffpath
echo "4,---------------------------"
pwd
echo "1,if rm /enggdata/SnifferLogs/* ?"
    read need
    case $need in
    yes|y)
        rm * -rf;
    echo "rm snifferlog successfully!";;   
    no|n)    
    echo "snifferlog not removed!";;
    esac
### end the script


echo "rm snifferlog successfully!";;  最后一句,必须是两个分号。

相关标签: shell