OGG運維優化腳本(五)-信息修改類--批量註釋
阿新 • • 發佈:2017-06-19
ogg oracle goldengate 腳本 數據同步 shell
文件名:comment.sh
路徑:$HOME/ggscript/ggcomment
功能:該腳本基於CBS用戶每月大批量註釋源端表進行數據清理的需求而設計
通過edit腳本選擇並調用
日誌路徑:$HOME/gglog/ggcomment
#!/bin/bash backuptime=`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 ls -lrt $HOME/ggserver/dirprm/e*.prm read -p "Please enter the prm file name:" val echo "Please Enter the table you need to annotate" read -n 1 vi annotmp echo "---annotate table --------" > ‘‘$HOME‘/gglog/ggcomment/annoLog-‘$backuptime‘.log‘ cat annotmp >> ‘‘$HOME‘/gglog/ggcomment/annoLog-‘$backuptime‘.log‘ cp $HOME/ggserver/dirprm/$val $HOME/ggserver/dirprm/bak/$val.$backuptime.bak echo "backup the ‘$val‘ to the ‘$HOME/ggserver/dirprm/bak/$val.$backuptime.bak‘" >> ‘‘$HOME‘/gglog/ggcomment/annoLog-‘$backuptime‘.log‘ echo ch echo "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 > table2 break; ;; "noparameter") sed ‘s/^/TABLE /‘ annotmp > table1 sed ‘s/$/;/‘ table1 > table2 break; ;; "REPLICAT") sed ‘s/^/MAP /‘ annotmp > table1 sed ‘s/$/,/‘ table1 > table2 break; ;; "exit") echo "process break" exit 2; ;; *) echo "Please select your choice :"1.parameter" "2.noparameter" "3.REPLICAT" "exit"" ;; esac done; echo $TAL i=1 num=`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‘
本文出自 “netsman” 博客,請務必保留此出處http://netsman.blog.51cto.com/5750076/1939635
OGG運維優化腳本(五)-信息修改類--批量註釋