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

xiaoxiao2025-08-13  29

#!/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 root@xxx.xxx.xxx.xxx:/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!";;  最后一句,必须是两个分号。

转载请注明原文地址: https://www.6miu.com/read-5034768.html

最新回复(0)