从unix shell脚本中的日期减去1小时

问题描述:

我在shell脚本中有以下内容。如何在保留格式的同时减去一小时?

I have the following in a shell script. How can I subtract one hour while retaining the formatting?

DATE=`date "+%m/%d/%Y -%H:%M:%S"`


以下命令适用于最新版本的GNU date

The following command works on recent versions of GNU date:

date -d '1 hour ago' "+%m/%d/%Y -%H:%M:%S"