SHELL编程 数字比较问题

weixin_41562942 2018-03-14 05:18:12
cat /srv/smartcare/fm/SDR_cwr_flow_classtype_17603.csv 是一个数字0
#!/bin/sh
cat /srv/smartcare/fm/SDR_cwr_flow_classtype_17603.csv
aa=$(awk -v b=0 '{print($1>b)?"1":"0"}' /srv/smartcare/fm/SDR_cwr_flow_classtype_17603.csv)
if [ $aa -eq "1" ]; then
echo -e "\n3 SDR_cwr_flow_classtype : is NORMAL " >check_result11.csv
else
echo -e "\n3 SDR_cwr_flow_classtype : is NOK " >check_result11.csv

fi
运行结果:
+ cat /srv/smartcare/fm/SDR_cwr_flow_classtype_17603.csv
0
++ awk -v b=0 '{print($1>b)?1:0}' /srv/smartcare/fm/SDR_cwr_flow_classtype_17603.csv
+ aa=1
+ '[' 1 -eq 1 ']'
+ echo -e '\n3 SDR_cwr_flow_classtype : is NORMAL '
文本就一个数字0
aa=$(awk -v b=0 '{print($1>b)?"1":"0"}' /srv/smartcare/fm/SDR_cwr_flow_classtype_17603.csv)
运行结果应该是0,但结果是1


...全文
344 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_41562942 2018-03-14
  • 打赏
  • 举报
回复
在lunix系统
金秋枣香 2018-03-14
  • 打赏
  • 举报
回复
楼主哪个平台测试的,我这边ubuntu 结果是0

23,116

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧