I would like to know if there is a way to get the number of seconds since UNIX in any POSIX compatible shell without resorting to non-POSIX languages ββlike perl, or using non-POSIX extensions like GNU awk strftime function,
Here are some solutions that I have already ruled out ...
date +%s // Doesn't work on Solaris
I saw several shell scripts that analyze the output of date , then seconds are output from the formatted date of the gregorian calendar, but they do not seem to take into account data, such as seconds of a jump.
GNU awk has a strftime function, but this is not available in standard awk .
I could write a small C program that calls the time function, but the binary will be architecture specific.
Is there a cross-platform way to do this using only POSIX-compatible tools?
I am tempted to abandon and accept perl addiction, which is at least widely deployed.
perl -e 'print time' // Cheating (non-POSIX), but should work on most platforms
source share