I trying to find out a weekday from last month dates in a loop but have an error
'past_month_date: command not found'
The $past_month_date was calculated right and has format 20200131 But if I'm using date then it works.
weekday=$(date +%a)
here is my shell script:
#!/bin/bash
day_num=$(date +%u)
date=$(date +%Y%m%d)
month=$(date +%m)
year=$(date +%Y)
if [ $day_num -eq 1 ]
then
for (( h = 2; h <= 31; h ++))
do
past_month_date=$(date -d "-1 month" +%Y%m$h)
echo $past_month_date
weekday=$(past_month_date +%a)
echo $weekday
#if [ $weekday -ne $sunday ]
#then
#....
#fi
done
fi