减去操作是错误的

时间:2016-01-08 01:26:38

标签: linux bash

我的脚本如下:

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值和不同的值。所以它不是正确的。这里有什么问题?

1 个答案:

答案 0 :(得分: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" ?