The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Ticks in seconds. mig28mx HP-UX 1 06-26-2007 08:43 PM
is there any way to excute script every N seconds? umen Shell Programming and Scripting 7 03-30-2006 04:06 AM
getting time in mili seconds Bhups UNIX for Dummies Questions & Answers 5 12-06-2005 10:34 AM
Get lines in 5 seconds Lestat Shell Programming and Scripting 16 06-20-2005 04:24 PM
how to get number of seconds captainzeb UNIX for Advanced & Expert Users 2 12-02-2003 06:12 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-19-2005
akrathi akrathi is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 41
seconds to hh:mm:ss

Any sleek way to convert seconds to hh:mm:ss format .
I know it can be done by mod and divide . Looking for a one liner if possible .

Example
3600 seconds = 01:00:00
3601 seconds = 01:00:01
  #2 (permalink)  
Old 10-19-2005
vertigo23's Avatar
vertigo23 vertigo23 is offline
Registered User
  
 

Join Date: Jul 2005
Location: SF, CA
Posts: 73
Perl solution

Dunno if it's the most concise, but it's what I came up with. Fun problem

Code:
#!/usr/bin/perl -w

$si=$ARGV[0];

$s=$si%60;
$m=(($si%3600)-$s)/60;
$h=$s/3600;
$h=~s/^(\d+).*/$1/;

print "$h:$m:$s\n";
Should be easy to turn that into a 1-liner.

Last edited by vertigo23; 10-19-2005 at 02:24 PM.. Reason: typoes
  #3 (permalink)  
Old 10-19-2005
akrathi akrathi is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 41
That's what I am doing using shell .Certainly not in this concise manner .Thanks for this .

My purpose was just to explore if I am missing something
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:58 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0