开发者

How to print the number of seconds since unix epoch in solaris shell

开发者 https://www.devze.com 2022-12-26 14:02 出处:网络
Is there a way to use unix date to print the number of seconds since epoch? I\'m open to using other standard shell commands if there is a way

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

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

(I'm using Solaris, so there i开发者_如何学编程sn't date "+"%s")

Thanks


perl -e 'print time'


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;
}

:-)


you can try nawk,(but try to double confirm with the perl commands and see if they give the same results)

nawk "BEGIN{print srand}"


Try this

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号