这是我正在运行的当前文件:
#!/bin/ksh -x
export BIN_DIR="../../env"
. $BIN_DIR/vdenv.ksh
success="DROP
CREATE TABLE
GRANT"
$worker_dir/runsql.ksh ddl X X > chnl_avt_v1.log
result=$(sed -e '/DROP/,/GRANT/!d' chnl_avt_v1.log)
if [ "$result" -eq "success" ]; then
echo "hi"
else
echo "NOO"
fi
以下是我收到的错误,即使我知道 $success 和 $result 是相同的。结果=DROP CREATE TABLE GRANT + [ DROP CREATE TABLE GRANT -eq success ] master_list_ddl.ksh[13]: DROP ^JCREATE TABLE^JGRANT: 语法错误 + echo NOO NOO
答案1
success
您在访问变量和比较运算符时出错:
if [ "$result" -eq "success" ]; then
显然必须是
if [ "$result" = "$success" ]; then