Can I search for a number that is less than 55 using grep?
Hello everyone.
I have created a bash shell script that reads another file and outputs the students names and grades based on the option used with the command. Example. Doe John A 86 Math I have used the cut command along with grep to display on the first name, last name and mark. choice=$1 case "$choice" in -a)cut -f1,1,3 datafile | grep -e [8][0-9] ;; -b) cut -f1,1,3 datafile | grep -e [7][0-9] esac My problem is I need to add an option which will display the students that have a grade lower than 55. I'm not sure how I can achieve this with grep. There are 12 students in the datafile, and their grades range from 29-100%. After I solve that problem I have to add an option which will give me the class average, but first things first. Oh, I can't use awk simply because I don't know how to use it, and I'm not supposed to know it yet. Yes it's a school thing. Any help would be appreciated Thanks. |
Since this is homework I'll just point you in the right direction, at least what i think is the right direction :)
use grep to get the numbers, use bash for the math. good luck |
Use better thread titles. Is it really that difficult?
|
You basically have it now. The only thing that you really need to change is the regular expression that you are using in your grep statement. Look into how to use the "|" in regular expressions as an or. From there, you should be able to coble it together. This is really handy to learn as you can use this in case statements as well if you want to do a certain action on a range of values.
|
That seems a bit of an odd way to get the data (-f1,1,3 twice(!)), wouldn't the -d option in cut be easier ?
|
All times are GMT -5. The time now is 02:28 AM. |