Sponsored Content
Full Discussion: Adding a List of Times
Top Forums Shell Programming and Scripting Adding a List of Times Post 302981254 by itkamaraj on Thursday 8th of September 2016 10:18:37 PM
Old 09-08-2016
Code:
#!/bin/bash

list="1:11:00 0:13:03 2:06:45"

h=0
m=0
s=0
for x in ${list}
do
        echo ${x}
        h=$(( h + ${x%%:*} ))
        Min=$(echo ${x%:*} | cut -d: -f2)
        m=$(( m + ${Min} ))
        s=$(( s + ${x##*:} ))
        #echo "H : ${h}"
        #echo "M : ${m}"
        #echo "S : ${s}"
done

m=$(( m + (s/60) ))
h=$(( h + (m/60) ))
m=$(( m % 60 ))
s=$(( s % 60 ))

echo "${h}hrs ${m}min ${s}sec

This User Gave Thanks to itkamaraj For This Post:
 

10 More Discussions You Might Find Interesting

1. AIX

how would you know your server was rebooted 3 times or 5 times

Is there such location or command to know how many times did you reboot your server in that particular day?in AIX. (3 Replies)
Discussion started by: kenshinhimura
3 Replies

2. UNIX for Dummies Questions & Answers

User Name and Password List/adding and removing users.

Hello everyone and let me start off by thanking anyone who can help with this. I work for a company that uses Unix as one of their servers. I'm not at all familar with Unix beyond logging after I restart the server:rolleyes: I'm looking for some command that will bring me up a list of current... (3 Replies)
Discussion started by: disgracedsaint
3 Replies

3. Shell Programming and Scripting

Selecting certain times from a list

Hi all, I have a list of times: ...10:02 15:34 20:05 01:51 06:55 09:00 05:52... That's just part of the list (its huge). How do I go about selecting certain times, e.g. just between 23:00 and 05:00 ?? (4 Replies)
Discussion started by: mikejreading
4 Replies

4. Shell Programming and Scripting

adding a list of numbers 3 by 3

i have a list of numbers like this; 124 235 764 782 765 451 983 909 ... and i want to make a sum with the first 3 of them then the next 3 and so on. 124+235+764=1123 782+765+451=1998 ... some ideas? (4 Replies)
Discussion started by: Tártaro
4 Replies

5. Shell Programming and Scripting

Need scripting help in :Adding 20% to a list of number :

Hi Experts, I want to add 20% to the values and get an output , please advise with script , awk etc, # cat datafile.txt 50.4053 278.383 258.164 198.743 4657.66 12.7441 646.787 1.56836 23.2969 191.805 53.3096 1.12988 999.058 4100.29 (2 Replies)
Discussion started by: rveri
2 Replies

6. Shell Programming and Scripting

Adding Characters to a Word List

If I had a word list with a large amount of words in it, how would I (using a unix command) add, say, 123 to the end of each word? EDIT: The word list is stored in a large text file. I need a command that applies the ending to each word in the file and saves the result in a new text file. (7 Replies)
Discussion started by: evillion
7 Replies

7. Programming

Problem with implementing the times() function in C (struct tms times return zero/negative values)

Hello, i'm trying to implement the times() function and i'm programming in C. I'm using the "struct tms" structure which consists of the fields: The tms_utime structure member is the CPU time charged for the execution of user instructions of the calling process. The tms_stime structure... (1 Reply)
Discussion started by: g_p
1 Replies

8. Shell Programming and Scripting

AWK adding prefix/suffix to list of strings

75 103 131 133 138 183 197 221 232 234 248 256 286 342 368 389 463 499 524 538 (5 Replies)
Discussion started by: chrisjorg
5 Replies

9. Solaris

PostgreSQL - Adding to SVCS list.

I'm having some troubles setting an instance of postgreSQL to automatically start upon system boot. I have two servers running this app, one is automatically starting the service, the other is not. I'm attempting to use the "svcadmin" command, however, apparently when I run a "svcs -a" search, the... (6 Replies)
Discussion started by: Nvizn
6 Replies

10. Shell Programming and Scripting

Adding Long List Of Large Numbers

Hi All, I have a file with long list of numbers. This file contains only one column. These numbers are very large. I am using following command: cat myfile.txt | awk '{ sum+=$1} END {print sum}' The output is coming in scientific notation. How do I get the result in proper format? ... (4 Replies)
Discussion started by: angshuman
4 Replies
VM(1)								      mgetty								     VM(1)

NAME
vm - VoiceModem is the program for handling the voice modem functionality from shell scripts ACTIONS
beep options [<frequency [<length in 0.001sec>]]> diagnostics options device name (e.g. ttyS2 dial options phone number help play options [<file names]+> record options file name shell options [<shell script [shell options]]> wait options [<time in seconds]> devicetest OPTIONS
-c n use compression type n -d n set i/o device -t, -m, -i, -e, -s, -H equals to -d <2,3,4,5,6,7> -l s set device string (e.g. -l ttyS2:ttyC0) -v verbose output -w use off / on hook signal from local handset to start and stop recording -x n set debug level -L n set maximum recording length in sec -P print first DTMF tone on stdout and exit -R read and print DTMF string on stdout and exit -S s set default shell for shell scripts (e.g. -S /bin/sh) -T n set silence timeout in 0.1sec -V n set silence threshold to <n> (0-100%%) SEE ALSO
vgetty(1) POD ERRORS
Hey! The above document had some coding errors, which are explained below: Around line 30: You forgot a '=back' before '=head1' Around line 32: '=item' outside of any '=over' Around line 71: You forgot a '=back' before '=head1' perl v5.10.1 2010-04-04 VM(1)
All times are GMT -4. The time now is 11:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy