Sponsored Content
Top Forums Shell Programming and Scripting Calculate Average time of one column Post 302934449 by Newman on Saturday 7th of February 2015 06:53:52 AM
Old 02-07-2015
Calculate Average time of a column

Hello dears,

I have a log file with records like below and want to get a average of one column based on the search of one specific keyword.

Code:
2015-02-07      08:15:28        10.102.51.100   10.112.55.101   "kevin.c"       POST    /mainportal/webflow/customerprofile/smsEmailNotications/loadSubCategories.do?&msisdn=374355752&categoryCode=GSM_19   0.391   200     1740

suppose keyword is "loadSubCategories" and response time is on "column 8" (0.391)

This command gives a average of all response time of column 8 but not with the given keyword.

Code:
awk '{ total += $8; count++ } END { print total/count }' file.log001

please let me know how to write it.

Thanks.

Last edited by Newman; 02-07-2015 at 12:38 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

calculate average of column 2

Hi I have fakebook.csv as following: F1(current date) F2(popularity) F3(name of book) F4(release date of book) 2006-06-21,6860,"Harry Potter",2006-12-31 2006-06-22,,"Harry Potter",2006-12-31 2006-06-23,7120,"Harry Potter",2006-12-31 2006-06-24,,"Harry Potter",2006-12-31... (0 Replies)
Discussion started by: onthetopo
0 Replies

2. UNIX for Dummies Questions & Answers

Use awk to calculate average of column 3

Suppose I have 500 files in a directory and I need to Use awk to calculate average of column 3 for each of the file, how would I do that? (6 Replies)
Discussion started by: grossgermany
6 Replies

3. Programming

calculate average

I have a file which is 2 3 4 5 6 6 so i am writing program in C to calculate mean.. #include<stdio.h> #include<string.h> #include <math.h> double CALL mean(int n , double x) main (int argc, char **argv) { char Buf,SEQ; int i; double result = 0; FILE *fp; (3 Replies)
Discussion started by: cdfd123
3 Replies

4. Shell Programming and Scripting

calculate the average of time series data using AWK

Hi, I have two time series data (below) merged into a file. t1 and t2 are in unit of second I want to calculate the average of V1 every second and count how many times "1" in V2 is occur within a second Input File: t1 V1 t2 V2 10.000000... (5 Replies)
Discussion started by: nica
5 Replies

5. Shell Programming and Scripting

Calculate average time using a script

Hello, I'm hoping to get some help on calculating an average time from a list of times (hour:minute:second). Here's what my list looks like right now, it will grow (I can get the full date or change the formatting of this as well): 07:55:31 09:42:00 08:09:02 09:15:23 09:27:45 09:49:26... (4 Replies)
Discussion started by: jaredhanks
4 Replies

6. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies

7. Shell Programming and Scripting

Calculate Average AWK

I want to calculate the average line by line of some files with several lines on them, the files are identical, just want to average the 3rd columns of those files.:wall: Example file: File 1 001 0.046 0.667267 001 0.047 0.672028 001 0.048 0.656025 001 0.049 ... (2 Replies)
Discussion started by: AriasFco
2 Replies

8. Shell Programming and Scripting

Transpose timestamp based on column values and calculate time difference

Hello Expert, I need to transpose Date-Timestamp based on same column values and calculate time difference. The input file would be as below and required output is mentioned in the bottom INPUT File ======== 08/23/2012 12:36:09 JOB_5340 08/23/2012 12:36:14 JOB_5340 08/23/2012... (2 Replies)
Discussion started by: asnandhakumar
2 Replies

9. Shell Programming and Scripting

Calculate the average of a column based on the value of another column

Hi, I would like to calculate the average of column 'y' based on the value of column 'pos'. For example, here is file1 id pos y c 11 1 220 aa 11 4333 207 f 11 5333 112 ee 11 11116 305 e 11 11117 310 r 11 22228 781 gg 11 ... (2 Replies)
Discussion started by: jackken007
2 Replies

10. Shell Programming and Scripting

Match first two columns and calculate percent of average in third column

I have the need to match the first two columns and when they match, calculate the percent of average for the third columns. The following awk script does not give me the expected results. awk 'NR==FNR {T=$3; next} $1,$2 in T {P=T/$3*100; printf "%s %s %.0f\n", $1, $2, (P>=0)?P:-P}' diff.file... (1 Reply)
Discussion started by: ncwxpanther
1 Replies
Average(3pm)						  LogReport's Lire Documentation					      Average(3pm)

NAME
Lire::Average - Lire class that implements the avg operator SYNOPSIS
use Lire::Average DESCRIPTION
Class that implements the avg operator. This operator will compute the average value of a DLF field in a group of DLF records. If the field used by average isn't a numeric fields, the number of different values in that field will be used as the numerator. It's possible to compute a weighted average by specifying a weighting field. By default, the average is a by record average. It's possible to compute a by different values average. The list of fields that's used to determine the different values if speficied in the by-fields attribute. METHODS
new( %params ) Creates a new Lire::Average object. In addition to the values supported by its parents, the by-fields and weight attributes will be initialized to the values specified in the %params argument. by_fields( [$new_by_fields] ) Returns the fields that are going to be used to count the different values which will made up the by part of the average. This a reference to an array of DLF field names. If the $new_by_fields parameter is set, it will be used as the new $by_fields value. It must be an array reference and should only contains valid field names for the current report specification's schema. weigth( [$new_weight] ) Returns the DLF field's name by which the values will be multiplied before being summed. You can change the weight field by specifying a new name as the $new_weight parameter. Use undef to remove the use of a weighting field. SEE ALSO
Lire::ReportSpec(3pm), Lire::ReportOperator(3pm), Lire::Aggregator(3pm), Lire::Aggregate(3pm). AUTHORS
Francis J. Lacoste <flacoste@logreport.org> Wolfgang Sourdeau <wsourdea@logreport.org> VERSION
$Id: Average.pm,v 1.17 2008/03/09 19:27:30 vanbaal Exp $ COPYRIGHT
Copyright (C) 2001-2004 Stichting LogReport Foundation LogReport@LogReport.org This file is part of Lire. Lire is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program (see COPYING); if not, check with http://www.gnu.org/copyleft/gpl.html. Lire 2.1.1 2008-03-09 Average(3pm)
All times are GMT -4. The time now is 04:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy