max values amd min values


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting max values amd min values
# 1  
Old 04-18-2007
max values amd min values

Hello every one, I have following data
HTML Code:
***CAMPAIGN 1998 CONTRIBUTIONS***

---------------------------------------------------------------------------

NAME                 PHONE             Jan  |  Feb  |  Mar |  Total Donated

---------------------------------------------------------------------------

Mike Harrington      (510) 555-1212  250.00   100.00  175.00  525.00

Christian Dobbins    (408) 555-1212  155.00    90.00  201.00  446.00

Susan Dalsass        (206) 555-1212  250.00    60.00   50.00  360.00

Archie McNichol      (206) 555-1212  250.00   100.00  175.00  525.00

Jody Savage          (206) 555-1212   15.00   188.00  150.00  353.00

Guy Quigley          (916) 555-1212  250.00   100.00  175.00  525.00

Dan Savage           (406) 555-1212  450.00   300.00  275.00  1025.00

Nancy McNeil         (206) 555-1212  250.00    80.00   75.00  405.00

John Goldenrod       (916) 555-1212  250.00   100.00  175.00  525.00

Chet Main            (510) 555-1212   50.00    95.00  135.00  280.00

Tom Savage           (408) 555-1212  250.00    68.00  200.00  618.00

Elizabeth Stachelin  (916) 555-1212  175.00    75.00  300.00  550.00

----------------------------------------------------------------------------

                               SUMMARY

----------------------------------------------------------------------------

The campaign received a total of $6137.00 for this quarter.

The average donation for the 12 contributors was $511.42.

The highest contribution was $450.00.

The lowest contribution was $15.00.
I wan to get this two out put
The highest contribution was $450.00.

The lowest contribution was $15.00

How can I get from the file.
I am able to get all the results but not able to find the last two result
this i got so far
Code:
BEGIN{FS=":"
      printf "\n\t\t\t***CAMPAIGN 1998 CONTRIBUTIONS***\n\n"
      print "-------------------------------------------------------------------------------" 
      printf"Name\t\t\tPHONE\t\t|  Jan  |  Feb  |  Mar | Total Donated\n"
      print "--------------------------------------------------------------------------------" 
     }
     {tot=$3+$4+$5
     qtr_tot=qtr_tot+tot
     printf"%-20s\t%s\t%4.2f\t%4.2f\t%3.2f\t%3.2f\n",$1,$2,$3,$4,$5,tot}
      
       
     
  END{print "------------------------------------------------------------------------------" 
      print"\t\t\t\t SUMMARY"
      print "------------------------------------------------------------------------------"       
      {printf"The total reveived for this quater is :$%6.2f\n",qtr_tot}
      {printf"The the avgerage total :$%6.2f\n",qtr_tot/12}
     }

can any one please help me.
Thank you

Last edited by devmiral; 04-19-2007 at 04:43 PM..
devmiral
# 2  
Old 04-18-2007
Please do not post your contributers' phone numbers on this site. Thanks.
# 3  
Old 04-18-2007
this are fake phone numbers.
Any solution please
devmiral
# 4  
Old 04-18-2007
Try this:
egrep 'lowest|highest' input_file
# 5  
Old 04-18-2007
thank you for your reply.
I have to search from datafile and from three columns Jan,feb and March.
I have to get the higest and lowest value of of this three column. so i think it is not that easy. for me.
Any help please
devmiral
# 6  
Old 04-18-2007
devmiral,
You specifically asked:
Quote:
I wan to get this two out put
The highest contribution was $450.00.
The lowest contribution was $15.00
How can I get from the file.
The "egrep" command will give you the output you asked for.

If now you changed your specifications to ask for the lowest and highest
of each month, it is an entire different situation that involves more coding.
# 7  
Old 04-18-2007
Thak you for your reply.
I have to get that values in the script. How can I get.
Sorry to bother you, also I want to get the corresponding name for that contribution.

this is my data file
Code:
Mike Harrington: (510) 548-1278:250:100:175
Christian Dobbins: (408) 538-2358:155:90:201
Susan Dalsass: (206) 654-6279:250:60:50
Archie McNichol:(206) 548-1348:250:100:175
Jody Savage: (206) 548-1278:15:188:150
Guy Quigley: (916) 343-6410:250:100:175
Dan Savage: (406) 298-7744:450:300:275
Nancy McNeil: (206) 548-1278:250:80:75
John Goldenrod: (916) 348-4278:250:100:175
Chet Main: (510) 548-5258:50:95:135
Tom Savage: (408) 926-3456:250:168:200
Elizabeth Stachelin: (916) 440-1763:175:75:300


Last edited by devmiral; 04-18-2007 at 04:18 PM.. Reason: detail requirement
devmiral
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Issue using awk to print min values for unique ids

I am using the following script to search for and print minimum values for each individual Fields (3-14) for each unique id (Field 1). But when the field contains a "-99.99" ( I am ignoring "-99.99") and when the minimum value is the first line of a new id (Field 1), the output does not print Field... (13 Replies)
Discussion started by: ncwxpanther
13 Replies

2. Shell Programming and Scripting

How to get min and max values using awk?

Hi, I need your kind help to get min and max values from file based on value in $5 . File1 SP12.3 stc 2240806 2240808 + ID1_N003 ID2_N003T0 SP12.3 sto 2241682 2241684 + ID1_N003 ID2_N003T0 SP12.3 XE 2239943 2240011 + ID1_N003 ID2_N003T0 SP12.3 XE 2240077 2241254 + ID1_N003 ... (12 Replies)
Discussion started by: redse171
12 Replies

3. Shell Programming and Scripting

Need to pick max values of the columns

Hi, I have sar disk reports like below sample: 01:01:00 hdisk24 0 0.0 0 0 0.0 0.0 hdisk15 0 0.0 0 3 0.0 5.5 hdisk20 0 0.0 2 1 0.0 1.9 hdisk19 1 ... (3 Replies)
Discussion started by: reddyr
3 Replies

4. Shell Programming and Scripting

Compare values in two files. For matching rows print corresponding values from File 1 in File2.

- I have two files (File 1 and File 2) and the contents of the files are mentioned below. - I am trying to compare the values of Column1 of File1 with Column1 of File2. If a match is found, print the corresponding value from Column2 of File1 in Column5 of File2. - I tried to modify and use... (10 Replies)
Discussion started by: Santoshbn
10 Replies

5. Programming

Getting Rows from a MySQL Table with max values?

I feel stupid for asking this because it seems that MYSQL code isn't working the way that I think it should work. Basically I wrote code like this: select * from `Test_DC_Trailer` HAVING max(DR_RefKey); Where the DR_RefKey is a unique numeric field that is auto iterated (like a primary key)... (7 Replies)
Discussion started by: Astrocloud
7 Replies

6. UNIX for Dummies Questions & Answers

[Solved] Print a line using a max and a min values of different columns

Hi guys, I already search on the forum but i can't solve this on my own. I have a lot of files like this: And i need to print the line with the maximum value in last column but if the value is the same (2 in this exemple for the 3 last lines) i need get the line with the minimum value in... (4 Replies)
Discussion started by: MetaBolic0
4 Replies

7. Shell Programming and Scripting

AWK script - extracting min and max values from selected lines

Hi guys! I'm new to scripting and I need to write a script in awk. Here is example of file on which I'm working ATOM 4688 HG1 PRO A 322 18.080 59.680 137.020 1.00 0.00 ATOM 4689 HG2 PRO A 322 18.850 61.220 137.010 1.00 0.00 ATOM 4690 CD ... (18 Replies)
Discussion started by: grincz
18 Replies

8. Shell Programming and Scripting

Local max values of a file

I have a data file of two columns (corresponding to the x and y axes of a graph) separated by a comma. I want to find the local maximum values and print them to a file. It has been a while since I've done any scripting and I've forgotten everything. I have a few basic questions. 1.) How do... (1 Reply)
Discussion started by: jemm
1 Replies

9. UNIX for Dummies Questions & Answers

Awk search for max and min field values

hi, i have an awk script and I managed to figure out how to search the max value but Im having difficulty in searching for the min field value. BEGIN {FS=","; max=0} NF == 7 {if (max < $6) max = $6;} END { print man, min} where $6 is the column of a field separated by a comma (3 Replies)
Discussion started by: Kirichiko
3 Replies

10. Shell Programming and Scripting

awk to print mon and max values of ranges

HI all I'm trying to write an awk script to print the min and max value in a range(s) contained in another file - the range values are in $2 EG 114,7964,1,y,y,n 114,7965,1,y,y,n 114,7966,1,y,y,n 114,7967,1,y,y,n 114,7969,1,y,y,n 114,7970,1,y,y,n 114,7971,1,y,y,n 114,7972,1,y,y,n... (3 Replies)
Discussion started by: Mudshark
3 Replies
Login or Register to Ask a Question