【发布时间】:2018-12-19 15:15:02
【问题描述】:
我在运行 SunOS 5.9 的服务器上有一个 korn shell 脚本,我需要将输出从 stat 传递到 touch 以便在对目录执行某些操作后重置修改后的时间戳,例如
#Get modified timestamp of directory
mtime=$(stat -c %y ${dirvar})
## Do something to directory that will alter its modified timestamp ##
#Reset modified timestamp of directory
touch -t "${mtime}" "${dirvar}"
我该怎么做?上面的代码返回错误touch: bad time specification
我试过了:
> stat -c %y ${dirvar} | awk '{ split($1, a, "-"); split($2, b, ":"); split(b[3], c, "."); print a[1]a[2]a[3]b[1]b[2]c[1]}'
拿这个:
stat -c %y tmp
2018-12-19 11:28:41.000000000 +0000
输出如下:
20181219112841
但我仍然收到相同的 touch: bad time specification 错误。
【问题讨论】: