![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ticks in seconds. | mig28mx | HP-UX | 1 | 06-26-2007 05:43 PM |
| is there any way to excute script every N seconds? | umen | Shell Programming and Scripting | 7 | 03-30-2006 01:06 AM |
| getting time in mili seconds | Bhups | UNIX for Dummies Questions & Answers | 5 | 12-06-2005 07:34 AM |
| Get lines in 5 seconds | Lestat | Shell Programming and Scripting | 16 | 06-20-2005 01:24 PM |
| how to get number of seconds | captainzeb | UNIX for Advanced & Expert Users | 2 | 12-02-2003 03:12 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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"; Last edited by vertigo23; 10-19-2005 at 11:24 AM. Reason: typoes |
|
#3
|
|||
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |