Sponsored Content
Full Discussion: seconds to hh:mm:ss
Top Forums UNIX for Dummies Questions & Answers seconds to hh:mm:ss Post 87052 by vertigo23 on Wednesday 19th of October 2005 02:23:37 PM
Old 10-19-2005
Perl solution

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

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 03:24 PM.. Reason: typoes
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

how to get number of seconds

How do I get the number of seconds since 1970, within a script, for the previous day at 23:59? I need this value to pass into a sql statement to cleanup records older than the previous day at midnight. It will be automated via cron so no hard coding allowed. Thanks! (2 Replies)
Discussion started by: captainzeb
2 Replies

2. Shell Programming and Scripting

Get lines in 5 seconds

Hello everybody, how i can get how many lines are writed in a file in the last 5 seconds? For ezample i have 'file1' that is filled by a process automatically and i neet to know how many lines with the word 'EXACTO' were filled the last 5 seconds, can somebody help me? I try with: tail -f... (16 Replies)
Discussion started by: Lestat
16 Replies

3. UNIX for Advanced & Expert Users

Time Difference in seconds

It is required to calculate time difference in seconds between epoch time (19700101 00:00:00) and any given date time (e.g. 20010214 14:30:30). Is there any command in unix to get it? Thanks in adv. (1 Reply)
Discussion started by: k_bijitesh
1 Replies

4. HP-UX

Ticks in seconds.

Hello all, Is there any thumb rule or aproximation of the equivalence in second of one tick? Thank you in advance. (1 Reply)
Discussion started by: mig28mx
1 Replies

5. Shell Programming and Scripting

Convert Seconds to hh:mm:ss

Hi All I need to convert a number of fields in a record from seconds to hh:mm:ss ( or possibly hhh:mm:ss ). I'm guessing awk is the way to go . File has multiple records and each record contains 101 fields - can awk handle that ? The seconds values will be in fields 3 - 101 and could be 0. ... (4 Replies)
Discussion started by: Mudshark
4 Replies

6. Shell Programming and Scripting

How to delay the process for few seconds

Hi, In my shell script, (as per the requirement), I am creating few files, and the processes are launched parallelly . (by using "&" at the end of the command line). As per the logic, I need to remove these files as well, after creating. But, the problem is, due to parallel processing,... (3 Replies)
Discussion started by: jitendriya.dash
3 Replies

7. UNIX for Dummies Questions & Answers

Sorting and wc -l w.r.t seconds

I have file with below data 00:00:00 00:00:00 00:00:00 00:00:01 00:00:01 00:00:01 00:00:01 00:00:01 00:02:01 00:02:01 00:02:01 so on till 23:59:59 I want count of seconds for each hour and minutes say for 00:00:00 its 3 and 00:00:01 its 5 and 00:02:01 its 3 and so on... (8 Replies)
Discussion started by: mirwasim
8 Replies

8. Red Hat

How to check that a particular value is epoch seconds?

how to verify that the following is epoch time. that is if i have given some random value like 34600 , how can i know it is epoch seconds (5 Replies)
Discussion started by: ramsavi
5 Replies

9. Ubuntu

Countdown timer with seconds

I would like this to work with seconds as well. #!/bin/bash # if ; then echo "Incorrect usage ! Example:" echo './CountDown.sh -d "Jun 10 2011 16:06"' echo 'or' echo './CountDown.sh -m 90' exit 1 fi now=`date +%s` if ; then until=`date -d... (7 Replies)
Discussion started by: drew77
7 Replies
error_handler(3erl)					     Erlang Module Definition					       error_handler(3erl)

NAME
error_handler - Default System Error Handler DESCRIPTION
The error handler module defines what happens when certain types of errors occur. EXPORTS
undefined_function(Module, Function, Args) -> term() Types Module = Function = atom() Args = [term()] A (possibly empty) list of arguments Arg1,..,ArgN This function is evaluated if a call is made to Module:Function(Arg1,.., ArgN) and Module:Function/N is undefined. Note that unde- fined_function/3 is evaluated inside the process making the original call. If Module is interpreted, the interpreter is invoked and the return value of the interpreted Function(Arg1,.., ArgN) call is returned. Otherwise, it returns, if possible, the value of apply(Module, Function, Args) after an attempt has been made to autoload Module . If this is not possible, the call to Module:Function(Arg1,.., ArgN) fails with exit reason undef . undefined_lambda(Module, Fun, Args) -> term() Types Module = Function = atom() Args = [term()] A (possibly empty) list of arguments Arg1,..,ArgN This function is evaluated if a call is made to Fun(Arg1,.., ArgN) when the module defining the fun is not loaded. The function is evaluated inside the process making the original call. If Module is interpreted, the interpreter is invoked and the return value of the interpreted Fun(Arg1,.., ArgN) call is returned. Otherwise, it returns, if possible, the value of apply(Fun, Args) after an attempt has been made to autoload Module . If this is not possible, the call fails with exit reason undef . NOTES
The code in error_handler is complex and should not be changed without fully understanding the interaction between the error handler, the init process of the code server, and the I/O mechanism of the code. Changes in the code which may seem small can cause a deadlock as unforeseen consequences may occur. The use of input is dangerous in this type of code. Ericsson AB kernel 2.14.3 error_handler(3erl)
All times are GMT -4. The time now is 07:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy