我的脚本如下:
for i in {"CON","PA","PRO","RE","S","UN","VO"};
do
count=$(sqlplus -S $user/$pass<<EOF
select count(distinct s.filename) as count
from cd.tbl_1 s
where s.dt like to_char(sysdate-1,'YYYYMMDD')||'%' and s.type='$i';
exit;
EOF)
yday=$(date --date="yesterday" +"%b %_d")
thecount=$(ls . -ltr | grep "$yday" | wc -l)
echo $i" ON DB $count DB files is lower than the number $((thecount-count)) files in folder
------------------------------------------------------------------------------------";
但有趣的是 $thecount
和 $count
的值完全相同,所以当我像上面那样使用减号运算时,它没有 0 值和不同的值。所以它不减正确。这里有什么问题?
最佳答案
I found my mistake,
count=$(sqlplus -S $user/$pass<<EOF
select count(distinct s.filename) as count
from cd.tbl_1 s
where s.dt like to_char(sysdate-1,'YYYYMMDD')||'%' and s.type='$i';
exit;
EOF)
this part is printing non-numeric values which is like below
COUNT ---------- 5663
that's why cannot any operation on those numbers.
So how do i select only numbers "5663" ?
关于linux - 减号操作错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34668074/