更新时间:2022-11-12 19:54:30
我希望以下解决方案可以为您提供帮助:
I hope this below solution can help you:
export day=08-30-2017
date -d "$day -$(date -d $day +%w) days"
这将始终打印给定日期(或日期本身)之前的星期日.
This will always print the Sunday before the given date (or the date itself).
date -d "$day -$(date -d $day +%u) days"
这将始终打印给定日期之前的星期日(而不是日期本身).
This will always print the Sunday before the given date (and never the date itself).