$ printf '%(%F)T\n' 'next month, first Monday' 2017-04-03
bash, since 4.2 now supports a
%(<format)T in its
printf buitin, but not the ability to parse this kind of date expression.
If you had to use
bash and wanted to use that
%(<format>)T, you could still do it without forking with something like:
printf -v code '%( t=$((%s + (12 - %-H) * 60 * 60)) increment=$((8 - %u)) current_month=%m)T' -1 eval "$code" until t=$((t + increment * 24 * 60 * 60)) # next Monday around mid-day printf -v code '%(date=%F month=%m)T' "$t" eval "$code" [ "$month" != "$current_month" ] # until be get to next month do increment=7 # the first increment is the number of days # til Monday. Next increments are just a week. done echo "$date"