Home Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Shell script to convert epoch time to real time

Tags
shell scripts

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 04-25-2011
Shell script to convert epoch time to real time

Dear experts,

I have an epoch time input file such as : -
Code:
1302451209564
1302483698948
1302485231072
1302490805383
1302519244700
1302492787481
1302505299145
1302506557022
1302532112140
1302501033105
1302511536485
1302512669550

I need the epoch time above to be converted into real time into an output file such as below. Im in malaysia which is GMT +8 : -

1302451209564 -10 Apr 2011 16:00:20

Last edited by Yogesh Sawant; 04-25-2011 at 05:40 AM.. Reason: added code tags
# 2  
Old 04-25-2011
Those are not valid timestamps, but here's the "script": (works with GNU date)
Code:
while read S; do date -d @$S; done <infile

# 3  
Old 04-25-2011
Thanks Frans. But im using Solaris 8. It does not seem to support date -d.
Is there another option? Thanks
# 4  
Old 04-25-2011
if you could use Perl:
Code:
# perl -e 'print scalar localtime(1302451209564), "\n";'
Wed Jan 14 00:09:24 43243
#

# 5  
Old 04-25-2011
Thanks Yogesh
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Convert a string to epoch time Girish19 Shell Programming and Scripting 1 02-01-2016 06:38 AM
Converting real time to epoch time vivek d r Shell Programming and Scripting 3 03-27-2013 05:06 AM
Convert to epoch time SkySmart Shell Programming and Scripting 2 02-19-2013 06:33 AM
Shell Script for Epoch Time Conversion hedkandi Shell Programming and Scripting 9 04-01-2012 10:55 PM
how to convert date time to epoch time in solaris anshuman0507 Shell Programming and Scripting 6 08-22-2009 10:28 PM
epoch time in shell script robsonde Solaris 14 05-12-2009 12:08 PM
Convert Epoch Time to Standard Date and Time & Vice Versa DrivesMeCrazy Shell Programming and Scripting 5 02-07-2009 12:40 AM
Convert Epoch time format to normal date time format in the same file rk4k Shell Programming and Scripting 3 11-19-2008 09:04 PM
EPOCH to real time? TheEngineer UNIX for Advanced & Expert Users 5 07-18-2006 08:30 AM
Convert from standard epoch time from a shell script? LordJezo Shell Programming and Scripting 4 09-18-2005 11:48 PM


All times are GMT -4. The time now is 01:36 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password