How to determine number of week of the month
Solution 1:
The date
command can't do this internally, so you need some external arithmetic.
echo $((($(date +%-d)-1)/7+1))
Edit: Added a minus sign between the % and the d
Solution 2:
You can use this:
Monday First week day
WEEKNUMBER=$(( 1 + $(date +%V) - $(date -d "$(date -d "-$(($(date +%d)-1)) days")" +%V) ))
Sunday Firs week daty
WEEKNUMBER=$(( 1 + $(date +%U) - $(date -d "$(date -d "-$(($(date +%d)-1)) days")" +%U) ))