02-02-2009
Script to find the average of a given column and also for specified number of rows??
Hi friends
I have 100 files in my directory. Each file look like this..
Temp1 Temp2 Temp3
MAS 1 2 3
MAS 4 5 6
MAS 7 8 9
Delhi 10 11 12
Delhi 13 14 15
Delhi 16 17 18
Delhi 20 21 19
Mumbai 22 46 56
Mumbai 67 34 54
..................................
.................................. so on.
I need a script which gives gives average of the column2 Temp2 for a given row(s) e.g. Delhi or MAS
I got an awk script some thing like below from this unix forum but it is giving the average of all the rows.
$ (cd awkdir ; ls | while read filename ; do awk '{sum+=$3} END { print "Average for " FILENAME " = ",sum/NR}' $filename ; done)
Can anyone please add the grep " MAS/Delhi/.... so on" command to the existing script so that I will get my desired output...
Many thanks in advance to evryone.. This is my first posting..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Anyone has a script or command in UNIX that can take 4 to five different numbers and calculate the average? (2 Replies)
Discussion started by: bbbngowc
2 Replies
2. UNIX for Dummies Questions & Answers
Hi All
I like to know how can we calculate the number of rows and the average of the values present in the file. I will not know what will be the rowcount, which will be dynamic in nature of the file.
eg.
29
33
48
30
28 (6 Replies)
Discussion started by: pk_eee
6 Replies
3. Shell Programming and Scripting
Hi Friends,
In continuation to my earlier post
https://www.unix.com/shell-programming-scripting/99166-script-find-average-given-column-also-specified-number-rows.html
I am extending my problem as follows.
Input:
Column1 Column2
MAS 1
MAS 4 ... (2 Replies)
Discussion started by: ks_reddy
2 Replies
4. Shell Programming and Scripting
Dear users,
I need your support, I have a file like this:
272134.548 6680572.715
272134.545 6680572.711
272134.546 6680572.713
272134.548 6680572.706
272134.545 6680572.721
272134.543 6680572.710
272134.544 6680572.715
272134.543 6680572.705
272134.540 6680572.720
272134.544... (10 Replies)
Discussion started by: Gery
10 Replies
5. UNIX for Dummies Questions & Answers
Could anybody help with this?
I have input below .....
david,39
david,39
emelie,40
clarissa,22
bob,42
bob,42
tim,32
bob,39
david,38
emelie,47
what i want to do is count how many names there are with different ages, so output would be like this ....
david,2
emelie,2
clarissa,1... (3 Replies)
Discussion started by: itsme999
3 Replies
6. Homework & Coursework Questions
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I am trying to complete a script which will allow me to find:
a) reads a value from the keyboard. (ask the... (4 Replies)
Discussion started by: dstewie
4 Replies
7. Shell Programming and Scripting
Dear All,
I have this file tab delimited
A 1 12 22
B 3 34 33
C 55 9 32
A 12 81 71
D 11 1 66
E 455 4 2
B 89 4 3
I would like to make the average every column where the first column is the same, for example,
A 6,5 46,5 46,5
B 46,0 19,0 18,0
C 55,0 9,0 32,0
D 11,0 1,0 66,0... (8 Replies)
Discussion started by: paolo.kunder
8 Replies
8. UNIX for Dummies Questions & Answers
I have a table, say this:
name1 num1 num2 num3 num4
name2 num5 num6 num7 num8
name3 num1 num3 num4 num9
name2 num8 num9 num1 num2
name2 num4 num5 num6 num4
name4 num4 num5 num7 num8
name5 num1 num3 num9 num7
name5 num6 num8 num3 num4
I want a code that will sort my data according... (4 Replies)
Discussion started by: FelipeAd
4 Replies
9. UNIX for Dummies Questions & Answers
I have a dataset with 120 columns. I would like to write a script, that takes the average of every two columns, starting from columns 2 and 3, and moving consecutively in frames of 3 columns, all the way until the last column.
The first column in the output file would be the averages of columns... (1 Reply)
Discussion started by: evelibertine
1 Replies
10. Shell Programming and Scripting
Experts,
Need your support for this awk script.
we have only one input file, all these column 1 and column 2 are in same file and have to do lookup for values in one file(column1 and column2) but output we need in another file
Need to grep row whose string contains 9K from column 1. When found... (6 Replies)
Discussion started by: as7951
6 Replies
LEARN ABOUT NETBSD
finsio
FINSIO(4) BSD Kernel Interfaces Manual FINSIO(4)
NAME
finsio -- Fintek LPC Super I/O driver
SYNOPSIS
finsio0 at isa? port 0x4e
DESCRIPTION
The finsio driver provides support for the Fintek F71805F, F71806F, F71862FG, F71872, F71882 and F71883 LPC Super I/O chips.
Only the Hardware Monitor device is supported and it provides you to monitor the sensors through the envsys(4) API.
The finsio Super I/O Hardware Monitor supports 15 sensors (this depends on the chip ID):
Sensor Units Typical Use
IN0 uV DC Internal 3.3Vcc
IN1 uV DC Memory Vtt
IN2 uV DC RAM Vcc
IN3 uV DC Chipset V
IN4 uV DC +5V
IN5 uV DC +12V
IN6 uV DC Vcc 1.5V
IN7 uV DC Vcore
IN8 uV DC Vsb
IN9 uV DC Vbat (optional)
Temp1 uK CPU Temperature
Temp2 uK Motherboard Temperature
Temp3 uK (undefined)
Fan0 RPM CPU Fan
Fan1 RPM User Fan1
Fan2 RPM User Fan2
SEE ALSO
envsys(4), envstat(8)
HISTORY
The finsio driver first appeared in NetBSD 5.0.
AUTHORS
The finsio driver was written by Geoff Steckel and Juan Romero Pardines.
BSD
April 3, 2008 BSD