【发布时间】:2017-09-06 07:50:30
【问题描述】:
我想比较一周中的当前日期并根据日期执行一组语句。
to_day=$(date +%a)
if[ "$to_day" = "Sun" ]
then
echo "Today is sunday"
echo "First day of the week"
elif[ "$to_day" = "Mon" ]
then
echo "Today is monday"
echo "Second day of the week"
等等……
我已经尝试过以下 if 格式
if[$to_day = "Tue"]
if["$to_day" -eq "Tue"]
if["$to_day" == 'Tue']
if["$to_day" = 'Tue']
但错误仍然存在,并且显示为“if[ Tue = Tue ]:Command not fount ”。我也试过上面的括号后面有空格。
【问题讨论】:
标签: string unix if-statement scripting