【问题标题】:bash if statement issue, cannot evaluate gtbash if 语句问题,无法评估 gt
【发布时间】:2013-06-01 23:16:54
【问题描述】:

这是我的 bash 脚本的一部分。我想跟踪脚本正在运行。 所以每次运行计数器都会增加,当计数器达到 X(我的测试为 3)时,就会发生一些事情。我也想重置计数。

计数器正在递增,

#!/bin/bash
counter=( `cat "/home/pi/auto/mark"` )

three=3


if [ "$counter2" -gt "$three" ]; then
     echo 1 > /home/pi/auto/daycheck

【问题讨论】:

  • 您声明counter,但在支票中使用counter2...
  • 另外,为了填写counter,请使用$(cat /home/pi/auto/mark)
  • 其实用$( < /home/pi/auto/mark).

标签: bash if-statement scripting


【解决方案1】:

我假设您的 $counter2 是一个错字

(( `</home/pi/auto/mark` > 3 )) && echo 1 > /home/pi/auto/daycheck

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多