前端之家收集整理的这篇文章主要介绍了
Shell-实际业务操作01,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
#!/bin/sh
EXIT_FAILURE=1
EXIT_SUCCESS=0
BEGIN_TIME=`date +%s`
SCRIPT_PATH=$(cd `dirname $0`; pwd)
SCRIPT_NAME=`basename $0`
LOG_LOCATION=/ocs/tools/OperCDR/logs
Check_TargetMenu(){
if [ ! -d $1 ];then
echo -e "Target Menu \033[31m$1 does not exist \033[0m,existing the script \033[31m$SCRIPT_PATH/$SCRIPT_NAME\033[0m,check fisrt please" >>$LOG_LOCATION/MvOtherCdrTo251.log 2>&1
exit $EXIT_FAILURE
else
cd $1
echo Current Directory $1
fi
}
TARGET_MENU='/ocs/data/output_bak0617'
Check_TargetMenu $TARGET_MENU
echo "==========================begin `date "+%Y-%m-%d %H:%M:%S"`===============================================" >>$LOG_LOCATION/MvOtherCdrTo251.log 2>&1
for operatingDir in `ls -d 25*`
do
if [ $operatingDir != '251' ]&&[ $operatingDir != '257' ]&&[ $operatingDir != '258' ]; then
echo $operatingDir
Current_oper_dir=$(cd $TARGET_MENU/$operatingDir && pwd)
echo Current_oper_dir $Current_oper_dir
Dir_Normal_bak=$Current_oper_dir/normal/bak
Check_TargetMenu $Dir_Normal_bak
Final_Menu=$TARGET_MENU/251/normal/bak
for file in `ls in*.s`
do
mv $file $Final_Menu
echo "$file moved to $Final_Menu successfully " >>$LOG_LOCATION/MvOtherCdrTo251.log 2>&1
done
fi
done
END_TIME=$(date +%s)
echo "==========================end `date "+%Y-%m-%d %H:%M:%S"`=================================================" >>$LOG_LOCATION/MvOtherCdrTo251.log 2>&1
echo "==========================time consuming $(($END_TIME - $BEGIN_TIME)) seconds=================================================" >>$LOG_LOCATION/MvOtherCdrTo251.log 2>&1
echo "" >>$LOG_LOCATION/MvOtherCdrTo251.log 2>&1
exit $EXIT_SUCCESS
原文链接:https://www.f2er.com/bash/392617.html