为什么添加sqlplus行会影响bash脚本中的echo输出?
出乎意料的是,在后面添加sqlplus时,行号会有所不同,这没有任何意义。有人能解释一下吗 当我注释掉“sqlplus”时,我的行数为721 当我从sqlplus行中删除注释符号散列时,我得到222个回显行计数,命令相同为什么添加sqlplus行会影响bash脚本中的echo输出?,bash,sqlplus,Bash,Sqlplus,出乎意料的是,在后面添加sqlplus时,行号会有所不同,这没有任何意义。有人能解释一下吗 当我注释掉“sqlplus”时,我的行数为721 当我从sqlplus行中删除注释符号散列时,我得到222个回显行计数,命令相同 ./general_check.sh | wc -l 一切都是一样的,为什么同一个echo命令有两个不同的行计数 常规检查。sh #!/bin/bash ## Declaration Section ## export account_user=`cat user_pass
./general_check.sh | wc -l
一切都是一样的,为什么同一个echo命令有两个不同的行计数
常规检查。sh
#!/bin/bash
## Declaration Section
##
export account_user=`cat user_pass`
export CUSTLIST="/tmp/special_list.lst"
export SQLDIR="../scripts"
$ORACLE_HOME/bin/sqlplus -S $account_user@db_name @${SQLDIR}/gen_special_list.sql
/bin/cat $CUSTLIST | while read CUST ORACLE_SID
do
########### 721 lines with sqlplus commented out, 222 when sqlplus below is commented in ##############
echo "|||||${CUST}|||||${ORACLE_SID}|||||"
#### trouble maker line below ####
sqlplus -S ${CUST}/${CUST}@${ORACLE_SID} @${SQLDIR}/ctx_silly.sql>> ../reports/ctx_silly.log
done
exit
移除wc-l,获得不同数量的回声,并将其复制过来,逐个计数。真的很奇怪,展示给一些人看,没有人能理解为什么会这样。我想我找到了原因。sqlplus出错了,有些会影响这个脚本检查sqlplus是否使用了stdin,如中所示
#!/bin/bash
## Declaration Section
##
export account_user=`cat user_pass`
export CUSTLIST="/tmp/special_list.lst"
export SQLDIR="../scripts"
$ORACLE_HOME/bin/sqlplus -S $account_user@db_name @${SQLDIR}/gen_special_list.sql
/bin/cat $CUSTLIST | while read CUST ORACLE_SID
do
########### 721 lines with sqlplus commented out, 222 when sqlplus below is commented in ##############
echo "|||||${CUST}|||||${ORACLE_SID}|||||"
#### trouble maker line below ####
sqlplus -S ${CUST}/${CUST}@${ORACLE_SID} @${SQLDIR}/ctx_silly.sql>> ../reports/ctx_silly.log
done
exit