【RAC】【Vim】Vim在編輯停止RAC服務指令碼的妙用(:v/NAME/d)

secooler發表於2009-02-19
:v/NAME/d

僅此一條短小精悍的命令,可將不包含“NAME”的所有行一次性的刪除掉,使用這種方法可以非常方便並快速地編輯停止RAC服務的指令碼,具體操作如下:

RACDB1@rac1 /home/oracle$ crs_stat > shutdown_services.sh
RACDB1@rac1 /home/oracle$ vi shutdown_services.sh

NAME=ora.RACDB.RACDB1.inst
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.RACDB.RACDB2.inst
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac2

NAME=ora.RACDB.db
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1

NAME=ora.RACDB.racdb_taf.RACDB1.srv
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1

:v/NAME/d

操作完成之後效果如下:
NAME=ora.RACDB.RACDB1.inst
NAME=ora.RACDB.RACDB2.inst
NAME=ora.RACDB.db
NAME=ora.RACDB.racdb_taf.RACDB1.srv
NAME=ora.RACDB.racdb_taf.RACDB2.srv
NAME=ora.RACDB.racdb_taf.cs
NAME=ora.rac1.ASM1.asm
NAME=ora.rac1.LISTENER_RAC1.lsnr
NAME=ora.rac1.gsd
NAME=ora.rac1.ons
NAME=ora.rac1.vip
NAME=ora.rac2.ASM2.asm
NAME=ora.rac2.LISTENER_RAC2.lsnr
NAME=ora.rac2.gsd
NAME=ora.rac2.ons
NAME=ora.rac2.vip
~                                                                   
~                                                                   
~                                                                   
~                                                                   
64 fewer lines                                     16,1          All

再使用“:%s/NAME=/crs_stop /g” 及完成該指令碼的編輯,編輯後的指令碼如下:
RACDB1@rac1 /home/oracle$ cat shutdown_services.sh
crs_stop ora.RACDB.RACDB1.inst
crs_stop ora.RACDB.RACDB2.inst
crs_stop ora.RACDB.db
crs_stop ora.RACDB.racdb_taf.RACDB1.srv
crs_stop ora.RACDB.racdb_taf.RACDB2.srv
crs_stop ora.RACDB.racdb_taf.cs
crs_stop ora.rac1.ASM1.asm
crs_stop ora.rac1.LISTENER_RAC1.lsnr
crs_stop ora.rac1.gsd
crs_stop ora.rac1.ons
crs_stop ora.rac1.vip
crs_stop ora.rac2.ASM2.asm
crs_stop ora.rac2.LISTENER_RAC2.lsnr
crs_stop ora.rac2.gsd
crs_stop ora.rac2.ons
crs_stop ora.rac2.vip

-- The End --



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/519536/viewspace-555626/,如需轉載,請註明出處,否則將追究法律責任。

相關文章