Sum talk time in bash


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Sum talk time in bash
# 1  
Old 07-16-2018
Sum talk time in bash

Hello, guys !
I need a little help Smilie

Lets say i have log files with "n" calls like this one :

Code:
""""" <+825080825462>","+825080825462","60197774588","from-internal",
"SIP/518-00013e14","SIP/eu.test.com_outgoing-00013e15","Dial",
"SIP/eu.test.com_outgoing/001110260196544577,300,T","2018-01-08 02:40:10",
"2018-01-08 02:40:47","2018-01-08 02:40:54","44.132781","56.755853","ANSWERED",

Talk time is 56 seconds (56.755853). I need command line, which sums the total talk time for the whole file.

Regards,
DF
# 2  
Old 07-16-2018
Where exactly are you stuck?
# 3  
Old 07-16-2018
Quote:
Originally Posted by vgersh99
Where exactly are you stuck?
Well, i tried to do it with that command line, but i didnt succeeded.

Code:
awk -F "," '{x+=$14}END{printf "%.0f", x}' FebruaryTest > FebTestCount.txt

# 4  
Old 07-16-2018
Code:
awk -F, '{gsub("[^-+0-9.,]","",$(NF-2));s+=$(NF-2)}END{print s}' myFile

This User Gave Thanks to vgersh99 For This Post:
# 5  
Old 07-20-2018
Thanks, it worked like a charm.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Basic Bash algorithm with sum/subtraction

Hi all, i'm making some test on a data file. Imagine i have two columns inside it : 80377,20 80377,20 80379,19 80378,20 80380,20 80382,20 80381,21 Just to understand how can it works, imagine to subtract 100 to the number in the first column when the other one in the second... (4 Replies)
Discussion started by: Board27
4 Replies

2. Shell Programming and Scripting

Script in bash that works only some of the time

I ran this script yesterday (in the background) /usr/bin/nohup myfilelocation/myscriptname.sh & the script worked perfectly. i ran it today (also in the background) and just sat there. So i killed it and ran it normally and it worked perfectly. Anyone suggest why it just sat there and... (8 Replies)
Discussion started by: twinion
8 Replies

3. Shell Programming and Scripting

Bash Sum up for spezific Numbers

Hello everyone, I need your assistance with bash. I want to sum up some numbers, that's not the big problem i think, but the values i want to some depending on another number. For example, I have a file with some rows of content. Number 1, Number 2, other content. I want to sum up number... (4 Replies)
Discussion started by: Bruder_Bruno
4 Replies

4. Shell Programming and Scripting

Bash Script Looping all the time

Hello, I have a database file, named data.txt, and a shell script (convert.sh) to convert data.txt from columns to row. Output file name will be column_to_row.txt In this example data.txt has only four rows. Format of data.txt is: info name surname telefon_nr Data.txt info boris... (1 Reply)
Discussion started by: baris35
1 Replies

5. Shell Programming and Scripting

Time Stap Diff using Bash

hi all kindly i want to subtract to time stamps like: t1=08:35:20 t2=08:36:58 diff=00:01:38 <<<< or diff=01:38 <<<< using bash thanks alot (9 Replies)
Discussion started by: teefa
9 Replies

6. Shell Programming and Scripting

Comparing time is bash

Hi, I have a question on comparing time using bash. Tried searching a lot up but couldn't figure it out. So I have this: CURRENT_TIME=$(date +%H:%M) if then echo "Continue" else echo "Quit" fi I tried a lot of different combinations of comparing, but nothing seems to work. Any help... (2 Replies)
Discussion started by: r4v3n
2 Replies

7. Shell Programming and Scripting

How to compare time in bash script?

Hi, Anyone know how to compare the time in bash script? I want to compare say 30 min. to 45 min. ( AIX ) Thanks. (1 Reply)
Discussion started by: sumit30
1 Replies

8. Shell Programming and Scripting

Print sum and relative value of the sum

Hi i data looks like this: student 1 Subject1 45 55 Subject2 44 55 Subject3 33 44 // student 2 Subject1 45 55 Subject2 44 55 Subject3 33 44 i would like to sum $2, $3 (marks) and divide each entry in $2 and $3 with their respective sums and print for each student as $4 and... (2 Replies)
Discussion started by: saint2006
2 Replies

9. Shell Programming and Scripting

Bash time and programming

I have inherited a C++ program which does not manage it's memory at all. It has a whole bunch of 'new' variables without many deletes. I believe it was the programmers intent to let the OS clean up. Correct me if I am wrong, but I believe the unix/linux systems clean up after the program... (1 Reply)
Discussion started by: JDKunk
1 Replies

10. Shell Programming and Scripting

bash script, pattern matching + sum

Hi guys, i have been struggling to achieve the following and therefor looking for some help. I am trying to write something that will summerize the following output from my switches for daily totals. Basicly if $1 $2 $3 doesnt change, we can keep adding up $4. Probably would use a awk print end... (3 Replies)
Discussion started by: Wratholix
3 Replies
Login or Register to Ask a Question