千家信息网

OGG运维优化脚本(五)-信息修改类--批量注释

发表于:2024-11-24 作者:千家信息网编辑
千家信息网最后更新 2024年11月24日,文件名:comment.sh路径:$HOME/ggscript/ggcomment功能:该脚本基于数据库每月大批量注释源端表进行数据清理,要求数据同步配合注释大量配置表而设计通过edit脚本选择并调用
千家信息网最后更新 2024年11月24日OGG运维优化脚本(五)-信息修改类--批量注释

文件名:comment.sh

路径:$HOME/ggscript/ggcomment

功能:该脚本基于数据库每月大批量注释源端表进行数据清理,要求数据同步配合注释大量配置表而设计

通过edit脚本选择并调用

日志路径:$HOME/gglog/ggcomment

#!/bin/bashbackuptime=`date +%Y%m%d-%H%M`echo "This script is used to annotate the specified table!(created by renyi)"echo $backuptime > ''$HOME'/gglog/ggcomment/InsertLog-'$backuptime'.log'read -n 1#输入需要进行批量注释操作的E进程文件名(prm结尾)ls -lrt $HOME/ggserver/dirprm/e*.prmread -p "Please enter the prm file name:"  val#输入你需要注释的表名,不要加TABLE和分号echo "Please Enter the table you need to annotate"read -n 1vi annotmpecho "---annotate table --------" > ''$HOME'/gglog/ggcomment/annoLog-'$backuptime'.log'cat  annotmp  >>  ''$HOME'/gglog/ggcomment/annoLog-'$backuptime'.log'#备份prm配置文件cp $HOME/ggserver/dirprm/$val $HOME/ggserver/dirprm/bak/$val.$backuptime.bakecho "backup the '$val' to the '$HOME/ggserver/dirprm/bak/$val.$backuptime.bak'"  >> ''$HOME'/gglog/ggcomment/annoLog-'$backuptime'.log'#选择操作类型echo checho "Operating table you want to belong to what state?"select ch in "parameter" "noparameter" "REPLICAT" "exit"do#全部需注释表带有参数case $ch in"parameter")                sed 's/^/TABLE /' annotmp > table1                        sed 's/$/,/' table1 > table2break;;;#全部需注释表不带有参数"noparameter")                sed 's/^/TABLE /' annotmp > table1                        sed 's/$/;/' table1 > table2break;;;"exit")    echo "process break"    exit 2;;;*) echo "Please select your choice :"1.parameter" "2.noparameter"  "exit"" ;;esacdone;echo $TALi=1num=`sed -n '$=' table2`#注释操作while [ "$i" -le "$num" ]do        TAL=`sed -n $i'p' table2`   #     echo $TAL    #    echo --$TAL        sed "s/$TAL/--$TAL/g"  $HOME/ggserver/dirprm/$val    > tmp2        cat  tmp2 > $HOME/ggserver/dirprm/$val        ((i++));done  echo "process complete"  >> ''$HOME'/gglog/ggcomment/annoLog-'$backuptime'.log'


0