Epoch time in Solaris

One way of getting epoch time in solaris is

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

Is there any other simple command that can be run from Korn Shell to display epoch time in solaris 5.10?

Simple and portable:

perl -le 'print time'
man perlfunc

Another approach:

nawk 'BEGIN { print srand() }'

From nawk manual:

srand([expr])   Set the seed value for rand to expr  or  use the time of day if expr is omitted. The pre-vious seed value will be returned.
2 Likes

I've read that in the man page many a time, but it never sank in...