【发布时间】:2019-02-25 14:52:40
【问题描述】:
我正在尝试对这些条件进行分组,但它正在返回:
awaited conditional binary operator
waiting for `)'
syntax error next to `$thetime'
` ( dateutils.dtest $thetime --gt '09:30:00' && dateutils.dtest $thetime --lt '11:00:00' ) ||'
我已经尝试过:
Groups of compound conditions in Bash test
#!/bin/bash
thetime=$(date +%H:%M:%S)
if [[
( dateutils.dtest $thetime --gt '09:30:00' && dateutils.dtest $thetime --lt '11:00:00' ) ||
( dateutils.dtest $thetime --gt '13:00:00' && dateutils.dtest $thetime --lt '17:00:00' )
]]; then
iptables -A OUTPUT -d 31.13.85.36 -j REJECT
else
iptables -A OUTPUT -d 31.13.85.36 -j ACCEPT
fi
【问题讨论】:
-
--gt不是bash运算符;无论dateutils.dtest是什么都支持它吗? -
是的,它来自 dateutils.dtest 参数
标签: linux bash firewall iptables