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...
This User Gave Thanks to cfajohnson For This Post:
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)
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)
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)
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)
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)
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)
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)
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 OPENSOLARIS
sum
sum(1B) SunOS/BSD Compatibility Package Commands sum(1B)NAME
sum - calculate a checksum for a file
SYNOPSIS
/usr/ucb/sum file...
DESCRIPTION
sum calculates and displays a 16-bit checksum for the named file and displays the size of the file in kilobytes. It is typically used to
look for bad spots, or to validate a file communicated over some transmission line. The checksum is calculated by an algorithm which may
yield different results on machines with 16-bit ints and machines with 32-bit ints, so it cannot always be used to validate that a file has
been transferred between machines with different-sized ints.
USAGE
See largefile(5) for the description of the behavior of sum when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWscpu |
+-----------------------------+-----------------------------+
SEE ALSO sum(1), wc(1), attributes(5), largefile(5)DIAGNOSTICS
Read error is indistinguishable from EOF on most devices; check the block count.
NOTES
sum and /usr/bin/sum (see sum(1)) return different checksums.
This utility is obsolete.
SunOS 5.11 8 Nov 1995 sum(1B)