您好,登錄后才能下訂單哦!
文件名:comment.sh
路徑:$HOME/ggscript/ggcomment
功能:該腳本基于數(shù)據(jù)庫每月大批量注釋源端表進行數(shù)據(jù)清理,要求數(shù)據(jù)同步配合注釋大量配置表而設(shè)計
通過edit腳本選擇并調(diào)用
日志路徑:$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 #輸入需要進行批量注釋操作的E進程文件名(prm結(jié)尾) ls -lrt $HOME/ggserver/dirprm/e*.prm read -p "Please enter the prm file name:" val #輸入你需要注釋的表名,不要加TABLE和分號 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' #備份prm配置文件 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 #全部需注釋表帶有參數(shù) case $ch in "parameter") sed 's/^/TABLE /' annotmp > table1 sed 's/$/,/' table1 > table2 break; ;; #全部需注釋表不帶有參數(shù) "noparameter") sed 's/^/TABLE /' annotmp > table1 sed 's/$/;/' table1 > table2 break; ;; "exit") echo "process break" exit 2; ;; *) echo "Please select your choice :"1.parameter" "2.noparameter" "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'
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。