为啥终端能打印出字符但是在脚本中就只能打印出空格?
#!/bin/bash
fps=(40.47 41.07 40.83 9.82 5.26 25.11)
count=0
for((i==0;i<${#fps[@]};i++))
do
echo ${fps[i]}
echo $fps |awk "BEGIN{a=${fps[i]};print a<"24" ? "lost":"get";}"
# echo $fps|awk "BEGIN{${fps[i]}>= 24"?"OK":"error";}"
# let count=count+1
输出:
done[root@node72 home]# ./111.sh
40.47
41.07
40.83
9.82
5.26
25.11
0
echo $count
请问,为啥在终端没有打印出lost和get?echo $fps |awk "BEGIN{a=${fps[i]};print a<"24" ? "lost":"get";}"这句话单独在终端是可以使用的,为啥到了脚本内就打印不出字符,只打印出空格呢?
------解决方案--------------------#!/bin/bash
fps=(40.47 41.07 40.83 9.82 5.26 25.11)
count=0
for((i==0;i<${#fps[@]};i++)); do
echo ${fps[i]}
echo $fps
------解决方案--------------------
awk -v a=${fps[i]} 'BEGIN{print a<24? "lost":"get";}'
# echo $fps
------解决方案--------------------
awk "BEGIN{${fps[i]}>= 24"?"OK":"error";}"
# let count=count+1
done