【发布时间】:2012-01-09 15:57:00
【问题描述】:
我编写了一个仅在工作时间执行 curl 调用的 bash 脚本。出于某种原因,当我添加“-a”运算符时,每小时比较失败(并且由于某种原因,我的 bash 无法识别“&&”)。
虽然脚本要大得多,但以下是相关部分:
HOUR=`date +%k`
if [ $HOUR > 7 -a $HOUR < 17 ];
then
//do sync
fi
脚本给了我错误:
./tracksync: (last line): Cannot open (line number): No such file
但是,这个比较并没有失败:
if [ $DAY != "SUNDAY" -a $HOUR > 7 ];
then
//do sync
fi
是我的语法错误还是我的 bash 有问题?
【问题讨论】:
标签: linux bash ubuntu comparison-operators