Question: Write a bash shell script called 08-numMajors that will do the following: i. Read data from a class enrollment file that will be specified on

Write a bash shell script called 08-numMajors that will do the following:

i. Read data from a class enrollment file that will be specified on the command line.

ii. If the file does not exist, is a directory, or there are more or less than one parameters provided, display an appropriate error/usage message and exit gracefully.

iii. Display the number of a specified major who are taking a given class. The following is a sample input file and a sample run. I will use a file in the same format as this one to test your script, but the one I use may have different data in it. Your script should work with whatever data is in the file I use, including other majors than the ones shown in the examples below.

Sample input file (~turk/NetworkingClass/08-ClassEnrollment-CIS350.txt):

Bill Both, 123456789, Computer Information Systems

Carla Carothers, 234567890, Computer Information Systems

Stephanie Williams, 345678901, Marketing

Aritrya Badopadhi, 456789012, Computer Science

Santhi Roopashree, 567890123, Computer Information Systems

Heather Williams, 678901234, Computer Information Systems

Dave Schroth, 789012345, Computer Science

input: $ 08-numMajors 08-ClassEnrollment-CIS350.txt #file in current dir

output:

4 Computer Information Systems

2 Computer Science

1 Marketing

input: $ 08-numMajors ~turk/NetworkingClass/08-ClassEnrollment-CIS350.txt #file in other dir

output:

4 Computer Information Systems

2 Computer Science

1 Marketing

input: $ 08-numMajors ClassEnrollmentFile.txt #file doesnt exist

output: ERROR: file 'ClassEnrollmentFile.txt' does not exist.

EXTRA CREDIT: For extra credit, make your output read like in the following example. Specifically: for any major with just one student, say is; for majors with more than one student, say are.

input: $ 08-numMajors ~turk/NetworkingClass/08-ClassEnrollment-CIS350.txt

output:

There are 4 Computer Information Systems majors.

There are 2 Computer Science majors.

There is 1 Marketing major.

There are a total of 7 students in this class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!