Berkeley CSUA MOTD:Entry 28219
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2024/11/23 [General] UID:1000 Activity:popular
11/23   

2003/4/24-25 [Computer/SW/Unix, Computer/SW/Languages/Perl] UID:28219 Activity:high
4/24    On systems without Perl, what's the easiest way to obtain the
        same results as perl -e 'print time()'?
                        \_ On systems with perl the easiest way is:
                           perl -e 'print $^T';
        \_ 5 lines of C code using libc gettimeofday
        \_ combine date with awk and do some simple math (in awk or with bc).
        \_ combine date with awk and do some simple math (in awk or
           with bc).
        \_ 'date' has %s time format.
           \_ That gives you the "current second", not the # of seconds
              since epoch time.
                \_ date +%s gives the # secs since Jan 1, 1970 on
                   FreeBSD and Linux. (It doesn't work at all on
                           if you compile gnudate on solaris it will work--psb
                   Solaris)
                        \- this is a gnudate extension.
                           if you compile gnudate on solaris it will
                           work--psb
                           \_ If he can compile stuff, then he
                              can just write a 3 line c pgm to
                              get the info he needs.