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!";; 最后一句,必须是两个分号。