Value too great for base (error token is “0925”)

后端 未结 3 705
盖世英雄少女心
盖世英雄少女心 2021-02-14 00:40

I have the following logic in my bash script:

#!/bin/bash
local_time=$(date +%H%M)

if (( ( local_time > 1430  && local_time < 2230 ) || ( local_ti         


        
3条回答
  •  滥情空心
    2021-02-14 01:08

    Following the advice from this blog, this works:

    #!/bin/bash
    local_time=`date +%H%M`
    local_time="$(( 10#$local_time ))"
    
    if (( ( local_time > 1430  && local_time < 2230 ) || ( local_time > 0300 && local_time < 0430 ) )); then
        echo "it is time!"
    fi
    

提交回复
热议问题