Sponsored Content
Top Forums Shell Programming and Scripting Converting seconds to minutes Post 303042529 by Scrutinizer on Saturday 28th of December 2019 02:03:49 AM
Old 12-28-2019
Because it is a an arithmetic operation (you are trying to divide a number by 60)

Therefore you need an arithmetic expansion ( see: Shell command language: arithmetic expansions )
so you can assign the result of the arithmetic expression to a variable (assignment means variable=value)

If you do not do that, in your example AnzahlUeberstunden=$AnzahlUeberstunden/60 what happens is that you assign the value of AnzahlUeberstunden concatenated with the text string /60, so the result becomes 2040/60.

--
My second suggestion is called an arithmetic expression (which can be used in shells like ksh93, bash, zsh) in which variables can be modified without an explicit variable assignment.

Last edited by Scrutinizer; 12-28-2019 at 03:15 AM..
This User Gave Thanks to Scrutinizer For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert minutes to hours, minutes, seconds

How would you convert lets say a 1000 minutes to hours, minutes, seconds (1 Reply)
Discussion started by: Vozx
1 Replies

2. Shell Programming and Scripting

how to display time in minutes n seconds...

Hi all, may i know how to display time in minutes and seconds(may be milliseconds and even smaller that ) in shell scripts.... (1 Reply)
Discussion started by: santy
1 Replies

3. HP-UX

a simple way of converting a date in seconds to normal date

Hi all! I'm working on a HPUX system, and I was wondering if there is a simple way to convert a date from seconds (since 1970) to a normal date. Thanks (2 Replies)
Discussion started by: travian
2 Replies

4. Shell Programming and Scripting

Difference in day-hours-minutes-seconds format

Hi experts, I am reading two log files and passing dates as output to a txt file. Code is given below: echo "Start Time:" >> Report.txt cat start.log | while read LINE1 do echo $DATE1 >> Report.txt done echo "End Time:" >> Report.txt cat end.log | while read LINE2 ... (7 Replies)
Discussion started by: Sreejith_VK
7 Replies

5. Shell Programming and Scripting

Converting past date to seconds

Need a little help developing a ksh script. Have read through Perderabo's datecalc routine and it does not seem to fit the function I am looking for. Basically what I am trying to do is find any file (in a specific directory) that was created within the last five minutes. I am not a programming... (3 Replies)
Discussion started by: synergy_texas
3 Replies

6. Shell Programming and Scripting

How to split numeric value into hours:minutes:seconds

I have a problem. I am working on a Call Detail Report system. Come to find out the phone switch does not report in seconds. It is a 5 digit field that reports h:mm:ss The problem is I have 1-5 digit numbers Ie 1 = 1 second and should be reported as 0:00:01 22 should be 0:00:22 321 should be... (5 Replies)
Discussion started by: truecall
5 Replies

7. Shell Programming and Scripting

Add or Subtract the hours,minutes or seconds in the the time variable

Hello All, I am working on script where I need to add hours,minutes or seconds in the time.Time is not the current but it could be future time.I thought I can store that time in variable and add hours.minutes or second but I am not able to add that in the time that is stores in a variable. Time... (9 Replies)
Discussion started by: anuragpgtgerman
9 Replies

8. Shell Programming and Scripting

Converting seconds to time

I have a list of time spans in seconds, and want to compute the time span as hh:mm:nn I am coding in bash and have coded the following. However, the results are wrong as "%.0f" rounds the values. Example: ftm: 25793.5 tmspan(hrs,min,sec): 7.16 429.89 25793.50 hh: 7 mm: 10 ss:... (2 Replies)
Discussion started by: kristinu
2 Replies

9. Shell Programming and Scripting

Converting time format as Integer to seconds

Hello, How can we convert date like format 20181004171050 in seconds ? I can able to convert till date but failing for HHMMSS. date -d "20181004" "+%s" output as 1538596800 . But when i add hhmmss it is failing date -d "20181004172000" "+%s" result Invalid date Kindly guide. Regards (16 Replies)
Discussion started by: sadique.manzar
16 Replies

10. UNIX for Beginners Questions & Answers

How to convert days hours minutes seconds to minutes?

Hi, please help with below time conversion to minutes. one column values: 2 minutes 16 seconds 420 msec 43 seconds 750 msec 0 days 3 hours 29 minutes 58 seconds 480 msec 11 seconds 150 msec I need output in minutes(total elapsed time in minutes) (2 Replies)
Discussion started by: ramu.badugula
2 Replies
XS::APItest::KeywordRPN(3pm)				 Perl Programmers Reference Guide			      XS::APItest::KeywordRPN(3pm)

NAME
XS::APItest::KeywordRPN - write arithmetic expressions in RPN SYNOPSIS
use XS::APItest::KeywordRPN qw(rpn calcrpn); $triangle = rpn($n $n 1 + * 2 /); calcrpn $triangle { $n $n 1 + * 2 / } DESCRIPTION
This module supplies plugged-in keywords, using the new mechanism in Perl 5.11.2, that allow arithmetic to be expressed in reverse Polish notation, in an otherwise Perl program. This module has serious limitations and is not intended for real use: its purpose is only to test the keyword plugin mechanism. For that purpose it is part of the Perl core source distribution, and is not meant to be installed. RPN expression syntax Tokens of an RPN expression may be separated by whitespace, but such separation is usually not required. It is required only where unseparated tokens would look like a longer token. For example, "12 34 +" can be written as "12 34+", but not as "1234 +". An RPN expression may be any of: 1234 A sequence of digits is an unsigned decimal literal number. $foo An alphanumeric name preceded by dollar sign refers to a Perl scalar variable. Only variables declared with "my" or "state" are supported. If the variable's value is not a native integer, it will be converted to an integer, by Perl's usual mechanisms, at the time it is evaluated. A B "+" Sum of A and B. A B "-" Difference of A and B, the result of subtracting B from A. A B "*" Product of A and B. A B "/" Quotient when A is divided by B, rounded towards zero. Division by zero generates an exception. A B "%" Remainder when A is divided by B with the quotient rounded towards zero. Division by zero generates an exception. Because the arithmetic operators all have fixed arity and are postfixed, there is no need for operator precedence, nor for a grouping operator to override precedence. This is half of the point of RPN. An RPN expression can also be interpreted in another way, as a sequence of operations on a stack, one operation per token. A literal or variable token pushes a value onto the stack. A binary operator pulls two items off the stack, performs a calculation with them, and pushes the result back onto the stack. The stack starts out empty, and at the end of the expression there must be exactly one value left on the stack. OPERATORS
These are the operators being added to the Perl language. rpn(EXPRESSION) This construct is a Perl expression. EXPRESSION must be an RPN arithmetic expression, as described above. The RPN expression is evaluated, and its value is returned as the value of the Perl expression. calcrpn VARIABLE { EXPRESSION } This construct is a complete Perl statement. (No semicolon should follow the closing brace.) VARIABLE must be a Perl scalar "my" variable, and EXPRESSION must be an RPN arithmetic expression as described above. The RPN expression is evaluated, and its value is assigned to the variable. BUGS
This module only performs arithmetic on native integers, and only a small subset of the arithmetic operations that Perl offers. This is due to it being intended only for demonstration and test purposes. The RPN parser is liable to leak memory when a parse error occurs. It doesn't leak on success, however. SEE ALSO
Devel::Declare, "PL_keyword_plugin" in perlapi AUTHOR
Andrew Main (Zefram) <zefram@fysh.org> COPYRIGHT
Copyright (C) 2009 Andrew Main (Zefram) <zefram@fysh.org> LICENSE
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.5 2012-11-03 XS::APItest::KeywordRPN(3pm)
All times are GMT -4. The time now is 06:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy