today=`date +%a`
if [ "$today" == "Mon" ]
then
monday=`date -dmonday +%Y%m%d`
else
monday=`date -dlast-monday +%Y%m%d`
fi
Is it the best way to set the “monday” variable with the date of the last monday?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
actually your logic is not always setting “last monday”. if today is monday, you would get current date value.
I feel your logic is ok. however one thing you may concern about is,
%agive you a localized weekday name. from man page:there is another format
%u, you could use, to make your script more portable.