请教date -d STRING的问题

请教date -d STRING的问题

请问上面的命令中对STRING的格式有什么要求?在前面的贴中,dearvoid用
复制内容到剪贴板
代码:
day=2005-01-01
while [ $day != 2006-01-01 ]; do
    echo $day
    day=$(date -d "$day +1 day" +%Y-%m-%d)
done
实现逐天递增,不知道有没有方法实现逐小时递增,我改了上面的SHELL,但是没实现。
3Q      
我也不太清楚那个STRING到底得怎么写
不过一个小时前可以这么用
复制内容到剪贴板
代码:
[0 No.622 huan@huan ~]$ date
2007年 05月 05日 星期六 22:59:15 CST

[0 No.623 huan@huan ~]$ date -d '1 hour ago'
2007年 05月 05日 星期六 21:59:23 CST

[0 No.624 huan@huan ~]$ date -d '2006-01-01'
2006年 01月 01日 星期日 00:00:00 CST

[0 No.625 huan@huan ~]$ date -d '2006-01-01 + 1 hour ago'
2005年 12月 31日 星期六 23:00:00 CST

[0 No.626 huan@huan ~]$
      
复制内容到剪贴板
代码:
27.6 Relative items in date strings
===================================

"Relative items" adjust a date (or the current date if none) forward or
backward.  The effects of relative items accumulate.  Here are some
examples:

     1 year
     1 year ago
     3 years
     2 days

   The unit of time displacement may be selected by the string `year'
or `month' for moving by whole years or months.  These are fuzzy units,
as years and months are not all of equal duration.  More precise units
are `fortnight' which is worth 14 days, `week' worth 7 days, `day'
worth 24 hours, `hour' worth 60 minutes, `minute' or `min' worth 60
seconds, and `second' or `sec' worth one second.  An `s' suffix on
these units is accepted and ignored.

   The unit of time may be preceded by a multiplier, given as an
optionally signed number.  Unsigned numbers are taken as positively
signed.  No number at all implies 1 for a multiplier.  Following a
relative item by the string `ago' is equivalent to preceding the unit
by a multiplier with value -1.

   The string `tomorrow' is worth one day in the future (equivalent to
`day'), the string `yesterday' is worth one day in the past (equivalent
to `day ago').

   The strings `now' or `today' are relative items corresponding to
zero-valued time displacement, these strings come from the fact a
zero-valued time displacement represents the current time when not
otherwise changed by previous items.  They may be used to stress other
items, like in `12:00 today'.  The string `this' also has the meaning
of a zero-valued time displacement, but is preferred in date strings
like `this thursday'.

   When a relative item causes the resulting date to cross a boundary
where the clocks were adjusted, typically for daylight saving time, the
resulting date and time are adjusted accordingly.

   The fuzz in units can cause problems with relative items.  For
example, `2003-07-31 -1 month' might evaluate to 2003-07-01, because
2003-06-31 is an invalid date.  To determine the previous month more
reliably, you can ask for the month before the 15th of the current
month.  For example:

     $ date -R
     Thu, 31 Jul 2003 13:02:39 -0700
     $ date --date='-1 month' +'Last month was %B?'
     Last month was July?
     $ date --date="$(date +%Y-%m-15) -1 month" +'Last month was %B!'
     Last month was June!

   Also, take care when manipulating dates around clock changes such as
daylight saving leaps.  In a few cases these have added or subtracted
as much as 24 hours from the clock, so it is often wise to adopt
universal time by setting the `TZ' environment variable to `UTC0'
before embarking on calendrical calculations.