Home > Mobile >  Problem getting the current time in seconds in bash shell
Problem getting the current time in seconds in bash shell

Time:11-02

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?

CodePudding user response:

For now, this works for me:

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

CodePudding user response:

Try with printf function.

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

1635846449
  • Related