any command like "date $s" on Solaris?


 
Thread Tools Search this Thread
# 1  
Old 07-24-2006
any command like "date $s" on Solaris?

Hi guys, I am trying to find the command on solairs which can get the second since 1970-01-01.

On linux, we have command 'date %s', so what is for solaris?
# 2  
Old 07-25-2006
I can not think of an existing command to display the raw number of seconds. I'm sure perl has something but it is not my forte. However, if you have a C compiler, here is a very simple program to give you what you want:

Code:
/*  esec.c - display seconds since 00:00:00 UTC, January 1, 1970  */
#include <stdio.h>
#include <time.h>

int main ( void )
{
    return ( printf ("%d\n", time (NULL)) );
}

Compile the code and place somewhere in your path, say,

Code:
# gcc esec.c -o /usr/local/bin/esec

Not exactly what you're looking for, I know, but I'm a bit of a C-biased old timer. That is, don't have the utility? Then write it yourself!
# 3  
Old 07-25-2006
Hi hegemar, thank you for your reply and your program!

I just figured out away which is much easier,

#perl -e 'print int(time)'

Have a good day! Smilie
 

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
awk variable into shell command "date -d": possible...? fbird3 Shell Programming and Scripting 3 06-12-2018 04:26 PM
awk "date" and "system" command phaethon Shell Programming and Scripting 2 12-13-2016 05:27 AM
Using "mailx" command to read "to" and "cc" email addreses from input file asjaiswal UNIX for Dummies Questions & Answers 2 10-11-2014 09:32 PM
Printer configuration Migration from Solaris 10 "LP" to Solaris 11 "CUPS" os2mac Solaris 0 10-31-2013 01:02 PM
Using external "date" command from awk treesloth Shell Programming and Scripting 3 06-23-2011 10:02 PM
awk command to replace ";" with "|" and ""|" at diferent places in line of file shis100 Shell Programming and Scripting 7 03-16-2011 08:59 AM
Can someone help me to convert the date format after get it from the "LAST REBOOT" command. pichitw Shell Programming and Scripting 3 08-18-2010 08:14 AM
Command Character size limit in the "sh" and "bourne" shell Roshan1286 Shell Programming and Scripting 1 10-29-2009 07:38 AM
Command Character size limit in the "sh" and "bourne" shell Roshan1286 UNIX for Advanced & Expert Users 1 10-29-2009 07:01 AM
Command Character size limit in the "sh" and "bourne" shell Roshan1286 UNIX for Dummies Questions & Answers 1 10-29-2009 07:01 AM
date -d "-2 weeks" on Solaris shtuks Solaris 1 07-17-2009 08:31 AM
xx=`date +"%a %b %d"`;rsh xxx grep "^$XX" zzz ? Browser_ice AIX 2 06-13-2009 08:39 AM
"mail" command sort by date thepurple Solaris 1 04-18-2009 07:57 AM
add seconds to: date"|"time"|"HHMMSS anaconga UNIX for Advanced & Expert Users 3 08-27-2008 01:17 PM
"man date" command does not work aptit UNIX for Dummies Questions & Answers 1 02-15-2002 07:58 AM