Today our task is: determine the number of days in the current month (31, 30, 29, or 28) — with a simple one-line expression in a bash or sh script.
Solution:
date -d "`date +'%m/01'`+1month -1day" +%d
Or inside a script:
#!/bin/sh
a=`date -d "\`date +'%m/01'\`+1month -1day" +%d`
echo $a
Comments