在date
的手册页中:
-d, --date=STRING display time described by STRING, not 'now'
听起来您应该输入准确的日期,但我发现 date -d "-1 day"
有效。
我只想要一个 date
命令的 -d option
格式列表。我用谷歌搜索,但没有找到。
最佳答案
从 man date
:
DATE STRING
The --date=STRING is a mostly free format human readable date string such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or even "next Thursday". A date string may contain items indicating calendar date, time of day, time zone, day of week, relative time, relative date, and numbers. An empty string indicates the beginning of the day. The date string format is more complex than is easily documented here but is fully described in the info documentation.
然后您可以获得更多信息和示例输入
info date
您可以在 Date input formats 中找到.
A date is a string, possibly empty, containing many items separated by whitespace. The whitespace may be omitted when no ambiguity arises. The empty string means the beginning of today (i.e., midnight). Order of the items is immaterial. A date string may contain many flavors of items:
- calendar date items
- time of day items
- time zone items
- combined date and time of day items
- day of the week items
- relative items
- pure numbers.
关于bash - Bash 命令日期的 -d 选项格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22450302/