Solaris and seconds since epoc

Hi,

In a Linux environment I can just go

date '+%s'

to get the seconds since epoc ... how do I get that value

in Solaris (any version, really)? It appears that strftime

on Solaris knows nothing about epoc, so I can't trivially

get date to display the value.

Cheers

[318 byte] By [nzirdosa] at [2007-11-27 5:50:08]
# 1
hopefully this isn't off your topic: http://www.issociate.de/board/post/274844/Epoc_date.html
cloakesa at 2007-7-12 15:37:29 > top of Java-index,Solaris Operating System,Solaris 10 Features...
# 2
I would just use perl.perl -le 'print time'-- Darren
Darren_Dunhama at 2007-7-12 15:37:29 > top of Java-index,Solaris Operating System,Solaris 10 Features...
# 3

thanks cloaks and Darren - I didn't mean to use perl, hence the

question about date (or a 'simple' sh solution'). Even though we

do use perl (and I use it quite happily myself) the preference

would be to avoid it - more staff here know sh (and the varied

unix tools) than perl.

Sorry for the late response!

Cheers

nzirdosa at 2007-7-12 15:37:29 > top of Java-index,Solaris Operating System,Solaris 10 Features...
# 4

I'm surprised there is no apparent way of doing this in Solaris, your two best options are to use perl or write a small script/c-program which you call 'epoch'.

Two other ways of getting the epoch;

nawk 'BEGIN { print srand()}'

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

You can always call perl in a shell script, i think the lines

#!/bin/sh

epoch=`perl -le 'print time'`

echo "$epoch"

is quite understandable to anyone who knows a bit of scripting..

.7/M.

mAbrantea at 2007-7-12 15:37:29 > top of Java-index,Solaris Operating System,Solaris 10 Features...
# 5
Appreciate that, and guess it's not too hard to read.Some of the old dogs around here are a tad resource restrained, and firing up an extra instance of perl underheavy load may not be a good idea. I'll investigate whatkind of impact I get from
nzirdosa at 2007-7-12 15:37:29 > top of Java-index,Solaris Operating System,Solaris 10 Features...