How to print the number of seconds since unix in the Solaris shell

Is there a way to use unix date to print the number of seconds since an era?

I am open to using other standard shell commands if there is a way

(I use Solaris, so there is no date "+"%s" )

thanks

+4
source share
4 answers

Well, since this is a programming site, I would just compile something like:

 #include <stdio.h> #include <time.h> int main (void) { printf ("%d\n",time(0)); return 0; } 

:-)

+3
source
 perl -e 'print time' 
+6
source

you can try nawk (but try doubling the confirmation with perl commands and see if they give the same results)

 nawk "BEGIN{print srand}" 
0
source

try it

/ usr / bin / truss / usr / bin / date 2> & 1 | grep ^ time | awk '{print $ 3}'

0
source

Source: https://habr.com/ru/post/1306236/


All Articles