I want to get yesterday date in YYYY-MM-DD
format.
In bash, I can get it by using date '+%F' -d "1 day ago"
. It gives the output as 2015-09-02
.
How can I get the same result in ksh
?
I want to get yesterday date in YYYY-MM-DD
format.
In bash, I can get it by using date '+%F' -d "1 day ago"
. It gives the output as 2015-09-02
.
How can I get the same result in ksh
?
Ksh
's printf
supports datetime manipulation:
# echo ${.sh.version}
Version AJM 93u+ 2012-08-01
# printf '%(%Y-%m-%d)T\n' today
2015-09-03
# printf '%(%Y-%m-%d)T\n' yesterday
2015-09-02
# printf '%(%Y-%m-%d)T\n' '5 days ago'
2015-08-29
#