OGG运维优化脚本(七)-信息修改类--快速注释-创新互联
文件名:note.sh
创新互联建站主要从事网站建设、成都网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务崂山,10年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792路径:$HOME/ggscript/ggnote
功能:该脚本用于注释指定行的配置表,配合重复值检查脚本repeat.sh使用
通过alias初始化入.profile或.bash_profile文件,通过指令note使用
日志路径:$HOME/gglog/ggnote
#!/bin/bash #参数验证 #格式为 进程 行数 if [ $# -eq 0 ]; then echo "note EXTRACT rowsnum" exit 2 fi if [ $# -eq 1 ]; then echo "note EXTRACT rowsnum" exit 2 fi backuptime=`date +%Y%m%d-%H%M` datenow=`date +%Y%m%d%H` val=$1 num=$2 val=`echo $val|tr a-z A-Z` #确定进程类型,如果为R开头的写入进程则跳出 if [ `echo $val|grep ^E` ];then IType=EXTRACT elif [ `echo $val|grep ^P` ];then IType=POST elif [ `echo $val|grep ^R` ];then echo "can not operate the REPLICAT process" echo "can not operate the REPLICAT process" > ''$HOME'/gglog/ggnote/note-'$backuptime'.log' echo "process break off" echo "process break off" >> ''$HOME'/gglog/ggnote/note-'$backuptime'.log' exit 2 else echo "only can operate the EXTRACT and the POST process" echo "can not operate the REPLICAT process" >> ''$HOME'/gglog/ggnote/note-'$backuptime'.log' echo "process break off" echo "process break off" >> ''$HOME'/gglog/ggnote/note-'$backuptime'.log' exit 2 fi echo "-------------------------" echo "The process name is $val" echo "The process name is $val" > ''$HOME'/gglog/ggnote/note-'$backuptime'.log' echo "-------------------------" echo "-------------------------" >> ''$HOME'/gglog/ggnote/note-'$backuptime'.log' cd $HOME/ggserver/dirprm val=`echo $val.PRM|tr A-Z a-z` tab=`sed -n $num'p' $val|grep ^TABLE` sed -n $num'p' $val|grep ^TABLE > $HOME/ggscript/ggnote/tmp cd $HOME/ggscript/ggnote/ NUX=`echo ${tab}|wc -c` echo $NUX if [ $NUX -le 2 ];then echo "It is not the table area!" echo "It is not the table area!" >> ''$HOME'/gglog/ggnote/note-'$backuptime'.log' echo "process break off" echo "process break off" >> ''$HOME'/gglog/ggnote/note-'$backuptime'.log' exit 2 else echo "lines have been identified: $tab" echo "lines have been identified: $tab" >> ''$HOME'/gglog/ggnote/note-'$backuptime'.log' fi #注释操作 echo "-------------------------" echo "-------------------------" >> ''$HOME'/gglog/ggnote/note-'$backuptime'.log' echo "backup the '$val' to the '$HOME/ggserver/dirprm/bak/$val.$backuptime.bak'" echo "backup the '$val' to the '$HOME/ggserver/dirprm/bak/$val.$backuptime.bak'" >> ''$HOME'/gglog/ggnote/note-'$backuptime'.log' cp $HOME/ggserver/dirprm/$val $HOME/ggserver/dirprm/bak/$val.$backuptime.bak sed "${num}s:TABLE:--TABLE:g" $HOME/ggserver/dirprm/$val > modtemp cat modtemp > $HOME/ggserver/dirprm/$val rm -f modtemp echo "-------------------------" echo "-------------------------" >> ''$HOME'/gglog/ggnote/note-'$backuptime'.log' echo "The Modify Results:" cd $HOME/ggserver/dirprm sed -n $num'p' $val echo "The Modify Results:" >> ''$HOME'/gglog/ggnote/note-'$backuptime'.log' sed -n $num'p' $val >> ''$HOME'/gglog/ggnote/note-'$backuptime'.log' echo "process complete" echo "process complete" >> ''$HOME'/gglog/ggnote/note-'$backuptime'.log'另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网页名称:OGG运维优化脚本(七)-信息修改类--快速注释-创新互联
分享网址:http://hbruida.cn/article/codddh.html