当前位置: 技术问答>linux和unix
shell中的特殊字符问题
来源: 互联网 发布时间:2017-05-10
本文导语: #!/bin/sh . /etc/profile . /home/cpcdata/test/cpc_env.sh db2 connect to dmdata > /dev/null sdata=`db2 -x "select CI_WA_ID||'~'||CI_WA_MODE||'~'||CI_WA_CONDITIONS||'~'||NVL(DECODE(RELATION_CI_WA_ID,'','X',RELATION_CI_WA_ID),'X') from VASS2.CPC_WEIGHTS_ANALYSIS where DET...
#!/bin/sh
. /etc/profile
. /home/cpcdata/test/cpc_env.sh
db2 connect to dmdata > /dev/null
sdata=`db2 -x "select CI_WA_ID||'~'||CI_WA_MODE||'~'||CI_WA_CONDITIONS||'~'||NVL(DECODE(RELATION_CI_WA_ID,'','X',RELATION_CI_WA_ID),'X') from VASS2.CPC_WEIGHTS_ANALYSIS where DETAIL_DATA_STATE=0 fetch first 1 rows only"`
if [ $? -ne 0 ]
then
echo $sdata
exit 1
fi
CI_WA_ID=`echo $sdata|awk -F '~' '{print $1}'`
CI_WA_MODE=`echo $sdata|awk -F '~' '{print $2}'`
CI_WA_CONDITIONS=`echo "$sdata"|awk -F '~' '{print $3}'`
RELATION_CI_WA_ID=`echo $sdata|awk -F '~' '{print $4}'`
CI_WA_ID=$CI_WA_ID
echo "CI_WA_ID:$CI_WA_ID"
echo "CI_WA_MODE:$CI_WA_MODE"
echo "CI_WA_CONDITIONS:$CI_WA_CONDITIONS"
echo "RELATION_CI_WA_ID:$RELATION_CI_WA_ID"
if [ ${CI_WA_MODE} -eq "1" ]
then
echo "label_user_group start!"
##create_table $CI_WA_ID
echo "$RELATION_CI_WA_ID"
if [ X$RELATION_CI_WA_ID != "XX" ];then
echo "OTHER GROUP IS NOT NULL UNION MINUS OR INTERSECT"
SQL_STR="INSERT INTO TAB_$CI_WA_ID SELECT PHONE_NO FROM ($CI_WA_CONDITIONS) T1,TAB_$RELATION_CI_WA_ID T2 WHERE T1.PHONE_NO=T2.PHONE_NO"
echo $SQL_STR
fi
fi
打印结果:
CI_WA_ID:2_j1390485120808_4
CI_WA_MODE:1
CI_WA_CONDITIONS:select * from vass2.test_users
RELATION_CI_WA_ID:45678
label_user_group start!
45678
OTHER GROUP IS NOT NULL UNION MINUS OR INTERSECT
select cpc_env.sh test.sh test2.sh from vass2.test_users
INSERT INTO TAB_2_j1390485120808_4 SELECT PHONE_NO FROM (select cpc_env.sh test.sh test2.sh from vass2.test_users) T1,TAB_45678 T2 WHERE T1.PHONE_NO=T2.PHONE_NO
. /etc/profile
. /home/cpcdata/test/cpc_env.sh
db2 connect to dmdata > /dev/null
sdata=`db2 -x "select CI_WA_ID||'~'||CI_WA_MODE||'~'||CI_WA_CONDITIONS||'~'||NVL(DECODE(RELATION_CI_WA_ID,'','X',RELATION_CI_WA_ID),'X') from VASS2.CPC_WEIGHTS_ANALYSIS where DETAIL_DATA_STATE=0 fetch first 1 rows only"`
if [ $? -ne 0 ]
then
echo $sdata
exit 1
fi
CI_WA_ID=`echo $sdata|awk -F '~' '{print $1}'`
CI_WA_MODE=`echo $sdata|awk -F '~' '{print $2}'`
CI_WA_CONDITIONS=`echo "$sdata"|awk -F '~' '{print $3}'`
RELATION_CI_WA_ID=`echo $sdata|awk -F '~' '{print $4}'`
CI_WA_ID=$CI_WA_ID
echo "CI_WA_ID:$CI_WA_ID"
echo "CI_WA_MODE:$CI_WA_MODE"
echo "CI_WA_CONDITIONS:$CI_WA_CONDITIONS"
echo "RELATION_CI_WA_ID:$RELATION_CI_WA_ID"
if [ ${CI_WA_MODE} -eq "1" ]
then
echo "label_user_group start!"
##create_table $CI_WA_ID
echo "$RELATION_CI_WA_ID"
if [ X$RELATION_CI_WA_ID != "XX" ];then
echo "OTHER GROUP IS NOT NULL UNION MINUS OR INTERSECT"
SQL_STR="INSERT INTO TAB_$CI_WA_ID SELECT PHONE_NO FROM ($CI_WA_CONDITIONS) T1,TAB_$RELATION_CI_WA_ID T2 WHERE T1.PHONE_NO=T2.PHONE_NO"
echo $SQL_STR
fi
fi
打印结果:
CI_WA_ID:2_j1390485120808_4
CI_WA_MODE:1
CI_WA_CONDITIONS:select * from vass2.test_users
RELATION_CI_WA_ID:45678
label_user_group start!
45678
OTHER GROUP IS NOT NULL UNION MINUS OR INTERSECT
select cpc_env.sh test.sh test2.sh from vass2.test_users
INSERT INTO TAB_2_j1390485120808_4 SELECT PHONE_NO FROM (select cpc_env.sh test.sh test2.sh from vass2.test_users) T1,TAB_45678 T2 WHERE T1.PHONE_NO=T2.PHONE_NO
|
这是啥!