#!/bin/bash
set -x
function rm OldRelease(){
awk -F "/" '{print $13}' release.log >> tmp.txt
while read line || [[ -n $line ]]
do
if [ ${line} ];then
rm -rf ${line}
sed -i "/${line}/d" release.log
fi
done < tmp.txt
if [ -f tmp.txt ];then
rm -f tmp.txt
fi
sed -i '$!d' release.log
}
ls -l |awk '{print $9}' |grep -v "^$" >dirList.txt
while read line || [[ -n $line ]]
do
if [[ ${line} =~ ^HiCloud.*$ ]];then
pushd /opt/hw/release/hitouch/${line}
rmOldRelease
popd
fi
done < dirList.txt
rm -f dirList.txt
release.log
2018-11-29:16:22:06 install 1.1.0.38.20181129161838 /opt/hw/release/hitouch/HiTouchCloud_CDps/20181129162206 taskid: 877f3dfd1c974e9a9ba119b8ecfb061b backup_path: None
2018-12-04:18:35:10 install 1.1.0.38.20181129161838 /opt/hw/release/hitouch/HiTouchCloud_CDps/20181204183510 taskid: 96982981aab147988f2461bd9f5a9995 backup_path: /opt/hw/release/hitouch/HiTouchCloud_CDps/20181129162206
2018-12-04:20:31:52 install 1.1.0.38.20181204202758 /opt/hw/release/hitouch/HiTouchCloud_CDps/20181204203152 taskid: b919f2a51bc14893a0edcc940a699b50 backup_path: /opt/hw/release/hitouch/HiTouchCloud_CDps/20181204183510
2018-12-04:20:34:32 install 1.1.0.38.20181204202758 /opt/hw/release/hitouch/HiTouchCloud_CDps/20181204203432 taskid: 3f3139430c0d4d74b0eca60e237df7a5 backup_path: /opt/hw/release/hitouch/HiTouchCloud_CDps/20181204203152