need some help..Comparison


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need some help..Comparison
# 1  
Old 02-23-2008
need some help..Comparison

I need some help which would probably be for most of you a simple script.

I need to read in the data from a .dat file and then compare avg to see who is the highest avg. Here is my script so far.

Code:
#!/bin/ksh
#reading in the data from lab3.dat
filename=$1
while read name o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 ; do
avg=0
sum=0
#adding in the information for one person
#for (( k=0 ; k<20 ; k++ ))
(( sum=$o1+$o2+$o3+$o4+$o5+$o6+$o7+$o8+$o9+$o10 ))

#getting the avg from one person
(( avg=$(echo "scale=4 ; ($sum/10)" | bc) ))
sd=0
(( sd=$(echo "scale=8 ; sqrt((((($o1-$avg)^2+($o2-$avg)^2+($o3-$avg)^2+($o4-$avg)^2+($o5-$avg)^2)+($o6-$avg)^2+($o7-$avg)^2+($o8-$avg)^2+($o9-$avg)^2+($o10-$avg)^2)/10))" | bc) ))
echo $name $avg $sd
done < $filename

As you can see right now it will just display back the names, avg, and sd per person. I need the highest avg posted only. TIA!

Last edited by vino; 02-24-2008 at 11:54 PM.. Reason: introduced code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help about comparison

Hello folks, I have two files, which have usernames, I want to see the contents of file1.txt which is missing in file2.txt and another comparison file2.txt contents which is missing in file1.txt. please suggest. file1.txt user u2 u8 a9 p9 p3 u4 z8 aaa ahe oktlo (7 Replies)
Discussion started by: learnbash
7 Replies

2. UNIX for Dummies Questions & Answers

date comparison

Hi friends, I would like to compare two dates in an IF statement. This is what I am trying, but it doesn't work. date=20120122 minus=6 if ; then ... fi what would the IF clause looks like? Thanks! :) (5 Replies)
Discussion started by: kokoro
5 Replies

3. UNIX for Dummies Questions & Answers

comparison

hi guys i need a program that can compare a value read from a com-port and one from the terminal. can somebody help me??? using linux kernel 2.6.14-M5 can only use standard function in sh and bash... (5 Replies)
Discussion started by: metal005
5 Replies

4. Shell Programming and Scripting

$((...)) and $[...] comparison

Does $((mathematical expression)) and $ mean the same? (7 Replies)
Discussion started by: proactiveaditya
7 Replies

5. Shell Programming and Scripting

String Comparison

Is there a way to compare the permission string of two files and output the string if they match? For ex: -rw-r--r-- 1 user newuser 0 2009-03-12 16:45 file2 -rw-r--r-- 1 user newuser 0 2009-03-12 16:46 fileone output: -rw-r--r-- If they don't match output will be just... (3 Replies)
Discussion started by: squardius
3 Replies

6. UNIX for Dummies Questions & Answers

Timestamp comparison

How do I compare 2 timestamps (ie... if 2008-02-13 10:48:58.502075 gt 2008-12-15 16:00:00.000000) (4 Replies)
Discussion started by: auzark
4 Replies

7. UNIX for Dummies Questions & Answers

Help with array comparison

I have an array @name with the below contents (index 7 and 8 are names): 1|1|2|2|I|2|0|DUNN|LACY|||||| 2|2|2|2|I|2|0|KOFE|ROGER|||||| 3|3|2|2|A|2|0|KOFOED|ROBERT|||||| 3|4|2|2|A|2|0|KOFOED|ROBERT|||||| 3|5|2|2|A|2|0|KOFOED|ROBERT|||||| 2|7|2|2|I|2|0|WILLIAMSON|JAMES||||||... (4 Replies)
Discussion started by: ChicagoBlues
4 Replies

8. Shell Programming and Scripting

list comparison

what is the easy way to compare checksums of sereral paramters by script: for example: #im creating a file containing a list of checksum parameters cksum /opt/LGTOaam51/data_source_types/UX_File_System/* > t1 #and another one cksum /opt/LGTOaam51/data_source_types/UX_File_System2/* > t2 ... (2 Replies)
Discussion started by: modcan
2 Replies

9. Shell Programming and Scripting

file comparison

hi I have 2 files to comapre ,in file a sible column it is numbers,in file b2 numbers and other values with coma separated. i want compare numbers in file a with file b,and the out put put should be in C with numbers in both file a and b along with other columns of file b. i used folowing... (7 Replies)
Discussion started by: satish.res
7 Replies

10. Filesystems, Disks and Memory

comparison

can anyone point me to a comparison of *nix file systems ? i think i prefer a journalling fs but i would like to see a comparison between several fs's before i make up my mind (2 Replies)
Discussion started by: cnf
2 Replies
Login or Register to Ask a Question
td_ta_enable_stats(3C_DB)				Threads Debugging Library Functions				 td_ta_enable_stats(3C_DB)

NAME
td_ta_enable_stats, td_ta_reset_stats, td_ta_get_stats - collect target process statistics for libc_db SYNOPSIS
cc [ flag... ] file... -lc_db [ library... ] #include <proc_service.h> #include <thread_db.h> td_err_e td_ta_enable_stats(const td_thragent_t *ta_p, int on_off); td_err_e_stats td_ta_reset(const td_thragent_t *ta_p); td_err_e td_ta_get_stats(const td_thragent_t *ta_p, td_ta_stats_t *tstats); DESCRIPTION
The controlling process can request the collection of certain statistics about a target process. Statistics gathering is disabled by default. Each target process has a td_ta_stats_t structure that contains current values when statistic gathering is enabled. The td_ta_enable_stats() function turns statistics gathering on or off for the process identified by ta_p, depending on whether or not on_off is non-zero. When statistics gathering is turned on, all statistics are implicitly reset as though td_ta_reset_stats() had been called. Statistics are not reset when statistics gathering is turned off. Except for nthreads and r_concurrency, the values do not change further, but they remain available for inspection by way of td_ta_get_stats(). The td_ta_reset_stats() function resets all counters in the td_ta_stats_t structure to zero for the target process. The td_ta_get_stats() function returns the structure for the process in tstats. The td_ta_stats_t structure is defined in <thread_db.h> and contains the following members: typedef struct { int nthreads; /* total number of threads in use */ int r_concurrency; /* requested concurrency level */ int nrunnable_num; /* numerator of avg runnable threads */ int nrunnable_den; /* denominator of avg runnable threads */ int a_concurrency_num; /* numerator, avg achieved concurrency */ int a_concurrency_den; /* denominator, avg achieved concurrency */ int nlwps_num; /* numerator, avg number of LWPs in use */ int nlwps_den; /* denominator, avg number of LWPs in use */ int nidle_num; /* numerator, avg number of idling LWPs */ int nidle_den; /* denominator, avg number of idling LWPs */ } td_ta_stats_t; The nthreads member is the number of threads that are currently part of the target process. The r_concurrency member is the current requested concurrency level, such as would be returned by thr_setconcurrency(3C). The remaining members are averages over time, each expressed as a fraction with an integral numerator and denominator. The nrunnable_num and nrunnable_den members represent the average num- ber of runnable threads. The a_concurrency_num and a_concurrency_den members represent the average achieved concurrency, the number of actually running threads. The a_concurrency_num and a_concurrency_den members are less than or equal to nrunnable_num and nrunnable_den, respectively. The nlwps_num and nlwps_den members represent the average number of lightweight processes (LWPs) participating in this process. They must be greater than or equal to a_concurrency_num and a_concurrency_den, respectively, since every running thread is assigned to an LWP, but there can at times be additional idling LWPs with no thread assigned to them. The nidle_num and nidle_den members represent the average number of idle LWPs. RETURN VALUES
TD_OK The call completed successfully. TD_BADTA An invalid internal process handle was passed in. TD_DBERR A call to one of the imported interface routines failed. TD_ERR Something else went wrong. ATTRIBUTES
See attributes(5) for description of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
libc_db(3LIB), thr_getconcurrency(3C), attributes(5) SunOS 5.10 20 Oct 1998 td_ta_enable_stats(3C_DB)