【发布时间】:2021-09-20 04:41:41
【问题描述】:
我有要求将字符串日期转换为以下格式并分配给变量以进行进一步处理。
Input is string as below
str = 20210709
Need to get yesterday date and change the format to %Y-%m-%d
(date -d 'str -1 days' +'%Y-%m-%d')
and i am expecting output in a variable like below
dt = 2021-06-09
I tried like below
dt = date -d '20210709 -1 days' +'%Y-%m-%d'
and the error as below
-bash: d: command not found
任何想法/建议将不胜感激。
【问题讨论】: