假设我只需要在上午11点10分到下午2点30分之间运行“command”。如何在Bash脚本中实现这个功能?
类似下面的伪代码:
类似下面的伪代码:
#!/bin/bash
while(1) {
if ((currentTime > 11:10am) && (currentTime <2:30pm)) {
run command;
sleep 10;
}
}
[
和]
运行良好,即[ $current -gt 1000 ]
不会抛出错误。 - xsc[
)一起使用,但无法与Bash内部指令一起使用。我不知道为什么 :/[ ~]$ test "09" -eq "9" && echo "ok"
结果是ok
和[ ~]$ [[ 09 -eq 9 ]] && echo "ok"
结果是-bash: [[: 09: value too great for base (error token is "09")
- Idriss Neumanntest
和[
时,你使用的是bash内置命令,而不是外部命令。对于外部命令,你需要使用command test
和command [
或在之前使用enable -n test
和enable -n [
。 - gniourf_gniourf