linux - 减号操作错误

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

最佳答案

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/

相关文章:

linux - 尝试访问Linux Amazon AWS实例中的某些目录

c++ - Ubuntu 20 不支持 MAP_FIXED_NOREPLACE

bash - 如何使用Spark添加HDFS数据

c++ - 在 bash 中获取进程的退出状态

json - 如何使用bash脚本将json值添加到json文件

c++ - libocci.so : undefined reference to

linux - 更改 Docker 容器

javascript - 启动 react native 应用程序时出错

arrays - bash + for 循环 + 输出索引号和元素

bash - Windows 10 原生 bash 确实响应 VSCode 中的 tasks.json