使用awk声明日期



我需要帮助在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"

当前状态下的脚本未成功执行。它失败,并出现以下错误。

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 ]]; 

相关内容

  • 没有找到相关文章