any command like "date $s" on Solaris?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers any command like "date $s" on Solaris?
# 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
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk variable into shell command "date -d": possible...?

Hello, there! I am trying to pass an awk variable into a shell command in order to collect the result into an awk variable; in Bash it does work, as in: v='2'; date -d "now + $v weeks" But in awk it does not, as in: v="2" "date -d 'now + v weeks'" | getline newdate close ("date -d 'now... (3 Replies)
Discussion started by: fbird3
3 Replies

2. Shell Programming and Scripting

awk "date" and "system" command

Hello experts! I need your help please I have a file.txt of which I want to extract 3rd and 4th columns with date with the form e.g.: 2016-11-25 03:14:50and pass them to "date" command, but also append the 9th column in a file as well. So I want to execute date -d '2016-11-25 03:14:50' ... (2 Replies)
Discussion started by: phaethon
2 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. Solaris

Printer configuration Migration from Solaris 10 "LP" to Solaris 11 "CUPS"

Need to find a way to import an LP printers.conf file to CUPS. I have some new Solaris 11.1 boxes that need to have 300 printers added. (0 Replies)
Discussion started by: os2mac
0 Replies

5. Shell Programming and Scripting

Using external "date" command from awk

For some dumb reason, I'm having the strangest hard time getting awk to convert epoch time to UTC human time. I'm using CentOS 5.5 and gawk 3.1.5. There are 2 approaches that I know. First, the strftime call: Tandy400 $ echo 1308607169 | awk '{print strftime("%c",$1)}' Mon 20 Jun 2011... (3 Replies)
Discussion started by: treesloth
3 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

Can someone help me to convert the date format after get it from the "LAST REBOOT" command.

Can someone help me to convert the date format after get it from the "LAST REBOOT" command. these is the standard output. bash-3.00# last reboot reboot system boot Fri Aug 6 15:07 reboot system down Fri Aug 6 15:04 reboot system boot ... (3 Replies)
Discussion started by: pichitw
3 Replies

8. Solaris

date -d "-2 weeks" on Solaris

Hi, I am trying to find solution how to get this on Solaris machine: $ MY_DATE=`date +%m/%d/%Y -d "-2 weeks"` $ echo $MY_DATE 07/01/2009 On Linux machine I can use flags like "+2 weeks", "+1 month", etc. but this doesn't work on Solaris. What is the most simplest way to write `date... (1 Reply)
Discussion started by: shtuks
1 Replies

9. AIX

xx=`date +"%a %b %d"`;rsh xxx grep "^$XX" zzz ?

AIX 4.2 I am trying to do an rsh grep to search for date records inside server logs by doing this : xx=`date +"%a %b %d"` rsh xxx grep "^$XX" zzz gives : grep: 0652-033 Cannot open Jun. grep: 0652-033 Cannot open 11. But if I do : xx=`date +"%a %b %d"` grep "^$XX" zzz it works... (2 Replies)
Discussion started by: Browser_ice
2 Replies

10. UNIX for Advanced & Expert Users

add seconds to: date"|"time"|"HHMMSS

Hey all, I have a shell that invokes a AWK. In this AWK i want invoke a function that receives 3 parameters: date: 20080831 time: 235901 duration: 00023 that function receive this 3 parameters and sum to this value two more seconds: 2008083123590100025 Remember that in case that... (3 Replies)
Discussion started by: anaconga
3 Replies
Login or Register to Ask a Question