Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我有一个像 2005 这样的变量,它代表一小时和一分钟,在这种情况下是 08:05pm。我如何从中减去 15 分钟。如果你使用 expr,你会得到类似 1990 的东西,这不是一个时间。如果您减去的时间少于剩余的时间,例如 2040-15=2025,则 expr 有效。但这不会每次都奏效。
使用 gnu date:
date
n='2005' date -d "$n 15 min ago" '+%H%M' 1950