LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Using vi to create bash shell script (https://www.linuxquestions.org/questions/linux-newbie-8/using-vi-to-create-bash-shell-script-658396/)

BBFeltham 07-26-2008 10:09 AM

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.

Nylex 07-26-2008 10:14 AM

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.

BBFeltham 07-26-2008 10:22 AM

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.

Nylex 07-26-2008 10:24 AM

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.

BBFeltham 07-26-2008 10:42 AM

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 (Post 3226954)
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.


unSpawn 07-26-2008 10:45 AM

Quote:

Originally Posted by BBFeltham (Post 3226951)
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 (Post 3226951)
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.

Tinkster 07-26-2008 02:30 PM

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

trickykid 07-28-2008 10:51 AM

Quote:

Originally Posted by unSpawn (Post 3226975)
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.

chrism01 07-28-2008 08:02 PM

Either way, I think we'd still like to see an attempted script.
;)

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


All times are GMT -5. The time now is 01:42 PM.