SHELL编程 数字比较问题
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