[英]Problem getting the current time in seconds in bash shell
I need to retrieve the current time in seconds in a old machine (bash version 4.3) and this command is not working.我需要在旧机器(bash 版本 4.3)中以秒为单位检索当前时间,但此命令不起作用。
date +%s
It retrieves "%s" Any idea of what is wrong here?它检索“%s” 知道这里有什么问题吗?
现在,这对我有用:
nawk 'BEGIN {srand();time=srand();print time}' </dev/null
Try with printf
function.尝试使用
printf
函数。
$ printf '%(%s)T' -1
1635846449
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.