1.格式化前
2.格式化后脚本
$CRS_HOME/bin/srvctl status database -d PEDBDB echo 'crs status' CRS_HOME=/u01/crs/oracle/product/10.2.0/crs RSC_KEY=$1 QSTAT=-u AWK=/usr/bin/awk $AWK \ 'BEGIN {printf "%-45s %-10s %-18s\n", " Resource name", "Target", "State"; printf "%-45s %-10s %-18s\n", "--------------", "------", "-----";}' $CRS_HOME/bin/crs_stat $QSTAT | $AWK \ 'BEGIN { FS="="; state = 0; } $1~/NAME/ && $2~/'$RSC_KEY'/ {appname = $2; state=1}; state == 0 {next;} $1~/TARGET/ && state == 1 {apptarget = $2; state=2;} $1~/STATE/ && state == 2 {appstate = $2; state=3;} state == 3 {printf "%-45s %-10s %-18s\n", appname, apptarget, appstate; state=0;}'