我在shell中完成以下脚本需要帮助。 请求的格式是打印上一个,当前和下一个工作日(应排除周末和假日)。 文字名称:holiday.txt
#!/usr/bin/sh
cur_date=`date +"%A %m/%d/%Y"`
cur_day=`date +"%A"`
yesterday=`TZ=AEDT+13 date +"%A %m/%d/%Y"`;
twodd_back=`TZ=AEDT+37 date +"%A %m/%d/%Y"`;
tomorrow=`TZ=AEDT-35 date +"%A %m/%d/%Y"`;
twodd_later=`TZ=AEDT-59 date +"%A %m/%d/%Y"`;
cdate=`date +"%m/%d/%Y"`
####################
echo "Previous Business Day is $yesterday"
if echo $yesterday|awk '{print $1}'=Saturday
then echo "Previous Business Day is $twodd_back"
fi
echo "Current Business Day is $ cur_date"
echo " Next Business Day is $tomorrow"
答案 0 :(得分:0)
处于当前状态的脚本无法成功执行。它失败并出现以下错误。
awk: syntax error at source line 1
context is
{print >>> $1}= <<< Saturday
awk: bailing out at source line 1
要修复它,请更改if语句。
if [[ `echo $yesterday | awk '{print $1}'` = Saturday ]];