简体   繁体   中英

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.

date +%s

It retrieves "%s" Any idea of what is wrong here?

现在,这对我有用:

nawk 'BEGIN {srand();time=srand();print time}' </dev/null

Try with printf function.

$ printf '%(%s)T' -1

1635846449

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM