FacebookTwitter
Hatrack River Forum   
my profile login | search | faq | forum home

  next oldest topic   next newest topic
» Hatrack River Forum » Active Forums » Books, Films, Food and Culture » Linux help

   
Author Topic: Linux help
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
Ok,

name phone # Jan Feb Mar Total Donated
-------------------------------------------
Dan Savage (514) 976-9903 250 340 670 4000

there's a list of said names, now what would the formula be for calculated the average total donated and the total amount donated for evryone on list?

IP: Logged | Report this post to a Moderator
TomDavidson
Member
Member # 124

 - posted      Profile for TomDavidson   Email TomDavidson         Edit/Delete Post 
When you say "Linux help," does this mean you want to run this sum from within the operating system, and not from a spreadsheet/ledger/word processing program?
Posts: 37449 | Registered: May 1999  |  IP: Logged | Report this post to a Moderator
ludosti
Member
Member # 1772

 - posted      Profile for ludosti   Email ludosti         Edit/Delete Post 
Now, I'm not familiar with linux, but the total amount donated would be the sum of all the figures in the Total Donated column and the average total donated (across all the people, rather than the average monthly donation from a single person) would be the average of all those same figures (the sum of the Total Donated divided by the number of people/rows).
Posts: 5879 | Registered: Apr 2001  |  IP: Logged | Report this post to a Moderator
ElJay
Member
Member # 6358

 - posted      Profile for ElJay           Edit/Delete Post 
quote:
Originally posted by TomDavidson:
When you say "Linux help," does this mean you want to run this sum from within the operating system, and not from a spreadsheet/ledger/word processing program?

And if so, why? Any spreadsheet program will do it quickly and easily for you.
Posts: 7954 | Registered: Mar 2004  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
This really has nothing to do with Linux, though I assume you want to do it on Linux.

As for formulas, I highly suggest thinking back to your first algebra class.

If you don't find that possible, the average for a value is found by adding up all the instances of that value and dividing by the total number of instances. If a dataset is 1,2,3, the average is 2, because that's 1+2+3 = 6, divided by the number of numbers in the dataset, 3.

The total amount donated by everyone is found by adding up the total amounts donated by each person. Since you'll do this on the route to figuring the average, I suggest doing this one first then using the total in the calculation of the average.

On the off chance you meant you wanted a program to do this, rather than a formula, and assuming there are no delimiters between the records, I'd delete the first two lines in the file (just to make it easy; we could use a command line program to chop them off for feeding to the next one), then go read the man page for awk. This tutorial is good, too: http://www.vectorsite.net/tsawk.html

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
ElJay: I wonder somewhat myself. It may be he's in a situation where its advantageous to automate the process, something spreadsheets are excellent at not doing but making people think they did.
Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
I was writing a script file, but nvm I solved it, next problem is that I need to sort a list of said names by their last names and gah I dont think i could explain it well enough...

{printf ("%5__%5" , $1, $2) | sort ~~~}

i need to sort by last names utilizing a space as a field separator, -F": " would be enough for awk but my teacher says I need something related to a -k command.

IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
nvm everything is A OH KAY. I handed in ym assignment and everything works.
IP: Logged | Report this post to a Moderator
TomDavidson
Member
Member # 124

 - posted      Profile for TomDavidson   Email TomDavidson         Edit/Delete Post 
Excellent, Blayne! I'm glad you got it working. Scripting is one of the most enjoyable things you can do with a decent shell.
Posts: 37449 | Registered: May 1999  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
bash shell I believe, we had a list of names, phone numebrs and campaign contributions as the examle above ^^, and we had to make a script that showed it in a special format and gave the average contribution, the total contribution, the highest subtotal contributiion per person.

Then for all people who contributed >= 500$ we had to print them out sorted alphabetically by last names and show only those who contributed more or equal to 500.

I ended up with alot of debugging. But eventually I figured out everything with the help of class mates and teachers. Now I have to prepare for next test by reviewing the assignment and reviewing the stuff in the book.

IP: Logged | Report this post to a Moderator
Dagonee
Member
Member # 5818

 - posted      Profile for Dagonee           Edit/Delete Post 
quote:
ElJay: I wonder somewhat myself. It may be he's in a situation where its advantageous to automate the process, something spreadsheets are excellent at not doing but making people think they did.
Maybe the way you work with spreadsheets. [Wink]
Posts: 26071 | Registered: Oct 2003  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
lol, no I do scripting utilizing the bash shell/emacs. I have no idea what a Linux/Unix spreadsheet us.
IP: Logged | Report this post to a Moderator
   

   Close Topic   Feature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:


Contact Us | Hatrack River Home Page

Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2