LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-26-2008, 10:09 AM   #1
BBFeltham
LQ Newbie
 
Registered: Jul 2008
Posts: 4

Rep: Reputation: 0
Using vi to create bash shell script


Need to find out how to calculate the highest mark and lowest mark in a list of grades.

Last edited by BBFeltham; 07-26-2008 at 10:13 AM.
 
Old 07-26-2008, 10:14 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Really you're not asking about vi at all, you're asking how to sort a list and get the highest and lowest values. sort, head and tail are commands that you'll want to use.
 
Old 07-26-2008, 10:22 AM   #3
BBFeltham
LQ Newbie
 
Registered: Jul 2008
Posts: 4

Original Poster
Rep: Reputation: 0
shell script help

The script must warn if a student is missing a mark or if the mark is unreadable (e.g. a letter instead of a number) from a list of student names and grades.
 
Old 07-26-2008, 10:24 AM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Instead of creating lots of threads for what appears to be the same problem, you should really just have one thread in which you describe what you're trying to do in full, where you're stuck, etc.
 
Old 07-26-2008, 10:42 AM   #5
BBFeltham
LQ Newbie
 
Registered: Jul 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Okay this is what I'm stuck on in full.

The file contains student names and grades in the following format:
#Name Marks
Joe Munson 92
Bob Smith 45
Jill Taylor 85
Jane Hathaway 65
Elliot Parsons 72
Mike Jackson 0

The script must be able to handle files of varying number of lines
The script must warn if a student is missing a mark or if the mark is unreadable (e.g. a letter instead of a number).
The script will calculate the class average, the highest mark and the lowest mark.
The output display shold look like this:
The name of the file is: studentmarks.txt
The class average is: 59.8%
The highest mark is: 92 (Joe Munson)
The lowest mark is : 0 (Mike Jackson)






Quote:
Originally Posted by Nylex View Post
Instead of creating lots of threads for what appears to be the same problem, you should really just have one thread in which you describe what you're trying to do in full, where you're stuck, etc.
 
Old 07-26-2008, 10:45 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by BBFeltham View Post
The script must warn if a student is missing a mark or if the mark is unreadable (e.g. a letter instead of a number) from a list of student names and grades.
Also this seems like a line straight out of an assignment. Help with homework isn't allowed, so if you want to evade that rule be creative about what you ask and how you ask for it.


Quote:
Originally Posted by BBFeltham View Post
The script must
BTW, asking for help with something implies phrasing it like a question. Now try to ask for stuff in your own words.

And like Nylex already asked you: please post whatever script or pseudo script you have and we'll help you correct and add things.

Last edited by unSpawn; 07-26-2008 at 10:54 AM.
 
Old 07-26-2008, 02:30 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Need to find out how to calculate the highest mark and lowest mark in a list of grades.
Code:
sort -g grades |sed -n -e '1p' -e '$p'
;}



Cheers,
Tink

Last edited by Tinkster; 07-26-2008 at 02:33 PM.
 
Old 07-28-2008, 10:51 AM   #8
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally Posted by unSpawn View Post
Also this seems like a line straight out of an assignment. Help with homework isn't allowed, so if you want to evade that rule be creative about what you ask and how you ask for it.
Actually, it is allowed, just the rules state this:

Quote:
Do not expect LQ members to do your homework - you will learn much more by doing it yourself.
They should just be set with the expectation that homework questions won't get much help or direct answers, maybe some guidance or push them to some documentation so they learn on their own. But they're definitely allowed according to the LQ rules, as if they weren't, then that should be rephrased to accommodate such rules.

And besides, the actual question makes it seem like it could be the teacher wanting to write a script for themselves to do their own type of automated reporting, etc.
 
Old 07-28-2008, 08:02 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,348

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
Either way, I think we'd still like to see an attempted script.


http://catb.org/~esr/faqs/smart-questions.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Script Help - Trying to create a variable inside script when run. webaccounts Linux - Newbie 1 06-09-2008 02:40 PM
how can create shell script user52 Linux - Newbie 4 11-27-2006 11:16 AM
How to use bash shell to create many users Linx2003 Linux - Software 1 09-04-2003 11:14 PM
How to use bash shell to create many users Linx2003 Programming 7 09-02-2003 01:00 PM
How to use bash shell to create many users Linx2003 Linux - General 1 09-02-2003 08:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration