Sponsored Content
Full Discussion: Average result of text file
Top Forums Shell Programming and Scripting Average result of text file Post 303026176 by simpsa27 on Wednesday 21st of November 2018 10:50:26 AM
Old 11-21-2018
Average result of text file

Hi all

I have created a script to allow me to gain a number of file times and how long they take to execute. I have been asked to get the average time for the log. The log will update every 5 minutes and never be empty.

Code:
141
152
157
161
168
169
171
179
202
207
229
651
666
714
759
795
823
845
853
863
931
978
982
1005
1063
1064
1071
1079
1107
1132
1150
1174
1212
1243
1303
1336
1378
1475
1591
1673
1697
1723
1729
1730

This is how the numbers are displayed within the text file (in milliseconds) - how do I write a script to add them all together and divide by the number of rows which could change every 5 minutes?

Incase you want too see the script I have created

Code:
get_file=`ls -rt localhost_access_log.*.txt|tail -1`
cat $get_file | tail -1000 | grep "objectId" | awk -F 'HTTP/1.1" 200' '{ print $2}'|awk -F' ' '{ print $2 }' | sort -n>/opt/product/apachetomcat/apm/epagent/epaplugins/centrica/correspondence_log_files/9080.txt

min_value=`cat /opt/product/apachetomcat/apm/epagent/epaplugins/centrica/correspondence_log_files/9080.txt|head -1`
max_value=`cat /opt/product/apachetomcat/apm/epagent/epaplugins/centrica/correspondence_log_files/9080.txt|tail -1`

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Outputting formatted Result log file from old 30000 lines result log<help required>

Well I have a 3000 lines result log file that contains all the machine data when it does the testing... It has 3 different section that i am intrsted in 1) starting with "20071126 11:11:11 Machine Header 1" 1000 lines... "End machine header 1" 2) starting with "20071126 12:12:12 Machine... (5 Replies)
Discussion started by: vikas.iet
5 Replies

2. Shell Programming and Scripting

Extract numbers from text file work out average

Just wondering if someone could assist me with shell script I'm trying to write. I need to read the final column of a text file (shown below) and workout what the average number is. The text file will have a variable number of lines, I just want the script to pull out the values in the final field... (14 Replies)
Discussion started by: rich@ardz
14 Replies

3. Shell Programming and Scripting

Displaying Result to a Text File

Hi; I am scripting in Shell and i want to write output (on screen) to a text file? ... | tee gcsw/output.txt doesnot work? :(:( (6 Replies)
Discussion started by: gc_sw
6 Replies

4. Shell Programming and Scripting

Append Text in Result File Name

Hi Below command is returning the list of files which having this string "MTL_SYSTEM_ITEMS". find . -name "*"|xargs grep -il MTL_SYSTEM_ITEMS Ex: Above command is returing 2 files (Out of 10 files 2 files having this string). ./file1.txt and ./file2.txt Here I want to append... (3 Replies)
Discussion started by: balajiora
3 Replies

5. Shell Programming and Scripting

Computing average values from multiple text files

Hi, first, I have searched in the forum for this, but I could not find the right answer. (There were some similar threads, but I was not sure how to adapt the ideas.) Anyway, I have a quite natural problem: Given are several text files. All files contain the same number of lines and the same... (3 Replies)
Discussion started by: rbredereck
3 Replies

6. UNIX Desktop Questions & Answers

Calculate average for rows in a text file

Dear Gurus, I have tab-delimited text files with matrix containing values. The first column is a identifier and other columns have the corresponding values. I would like to calculate the average value (total number/number of entries) for all entries from 2nd column to the last column in row... (3 Replies)
Discussion started by: Unilearn
3 Replies

7. Shell Programming and Scripting

How to output thre result to a text file?

Dear All I have a script file like the following: ..... ..... Variable_1 = 888 Variable_2 = 999 ..... MyExternalProgram Myfile ..... The line MyExternalProgram Myfile will generate some number, Say 777 Now I hope I can output the result of above codes to a text file,... (2 Replies)
Discussion started by: littlewenwen
2 Replies

8. Shell Programming and Scripting

Save result to a text file

Currently I have a perl code to combine two different files. #! /usr/bin/perl -w use strict; open FP1,"A.txt"; open FP2,"B.txt"; my ($l1,$l2); while(1) { $l1=<FP1>; chomp $l1; $l2=<FP2>; chomp $l2; last unless(defined $l1 or defined $l2); print "$l1 $l2\n"; } close FP2;... (4 Replies)
Discussion started by: Tzeronone
4 Replies

9. Shell Programming and Scripting

Hit multiple URL from a text file and store result in other test file

Hi, I have a problem where i have to hit multiple URL that are stored in a text file (input.txt) and save their output in different text file (output.txt) somewhat like : cat input.txt http://192.168.21.20:8080/PPUPS/international?NUmber=917875446856... (3 Replies)
Discussion started by: mukulverma2408
3 Replies

10. Shell Programming and Scripting

awk to parse file and display result based on text

I am trying using awk to open an input file and check a column 2/field $2 and if there is a warning then that is displayed (variantchecker): G not found at position 459, found A instead. The attached Sample1.txt is that file. If in that column/field there is a black space, then the text after... (6 Replies)
Discussion started by: cmccabe
6 Replies
APM(1)																	    APM(1)

NAME
apm - interface with the APM subsystem SYNOPSIS
apm [ -VvmMsSdin ] DESCRIPTION
This command requires the Advanced Power Management subsystem. If run without arguments it reads /proc/apm and presents the output in a human-readable format. Given a -S or -s option it requests that the machine be put into the APM standby or the APM suspend state, respectively. For a brief description of these states, see apmd(8). OPTIONS
-V, --version Print the version of the program and exit. -v, --verbose Also print version information for the APM subsystem. The APM subsystem consists of power-management hardware, firmware usually referred to as the APM BIOS and a driver in the operating system kernel. -m, --minutes Print the time remaining as a number of minutes. The default is to print the time remaining in "hours:minutes" format. -M, --monitor Continuously monitor and update the status information. Assumes that the standard output is a terminal. -S, --standby Request that the machine be put into the APM standby state. -s, --suspend Request that the machine be put into the APM suspend state. -d, --debug Print APM status information in a format more useful for debugging. Implies -v. FILES
/proc/apm AUTHOR
This program was written by Rik Faith (faith@cs.unc.edu) and may be freely distributed under the terms of the GNU General Public License. There is ABSOLUTELY NO WARRANTY for this program. The current maintainer is Avery Pennarun (apenwarr@worldvisions.ca). SEE ALSO
xapm(1), apmd(8). January 2004 APM(1)
All times are GMT -4. The time now is 01:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy