1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
S_A_V [24]
3 years ago
10

(6 pts) 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.
Computers and Technology
1 answer:
Levart [38]3 years ago
6 0

Answer:

Check the explanation

Explanation:

Script:

#!/usr/bin/ksh

#using awk to manipulated the input file

if [ $# != 1 ]

then

echo "Usage: 08-numMajors.sh <file-name>"

exit 1

fi

if [ -f $1 ]

then

awk '

BEGIN {

FS=","

i=0

flag=0

major[0]=""

output[0]=0

total=0

}

{

if ($3)

{

for (j=0; j<i; j++)

{

# printf("1-%s-%s\n", major[j], $3);

if(major[j] == $3)

{

flag=1

output[j] = output[j] + 1;

total++

}

}

if (flag == 0)

{

major[i]=$3

output[i] = output[i] + 1;

i++;

total++

}

else

{

flag=0

}

}

}

END {

for (j=0; j<i; j++)

{

if(output[j] > 1)

printf("There are %d `%s` majors\n", output[j], major[j]);

else

printf("There is %d `%s` major\n", output[j], major[j]);

}

printf("There are a total of %d students in this class\n", total);

}

' < $1

else

echo "Error: file $1 does not exist"

fi

Output:

USER 1> sh 08-numMajors.sh sample.txt

There are 4 ` Computer Information Systems` majors

There is 1 ` Marketing` major

There are 2 ` Computer Science` majors

There are a total of 7 students in this class

USER 1> sh 08-numMajors.sh sample.txtdf

Error: file sample.txtdf does not exist

USER 1> sh 08-numMajors.sh

Usage: 08-numMajors.sh <file-name>

USER 1> sh 08-numMajors.sh file fiel2

Usage: 08-numMajors.sh <file-name>

You might be interested in
Universal Containers are using Salesforce for Order Management and has integrated with an in-house ERP system for order fulfilme
Crazy boy [7]

Answer:

1. The change can be performed in Production, as it is a configuration change.

2. Integration with the ERP system may not function as expected.

Explanation:

3 0
3 years ago
Como realizar un cuadro comprativo?​
Kruka [31]
How to make a comparison chart?
3 0
3 years ago
What is the difference between a prefix and postfix in Java?
Doss [256]

Answer:

prefix comes first

Explanation:

pre means before, and post means after.

7 0
3 years ago
Suppose that a queue is implemented using a circular array of size 12. What is the value of last after the following operations?
otez555 [7]

Answer:

10

Explanation:

An enqueue operation is a function that adds an element(value) to a queue array. A dequeue operations removes an element from a queue array. Queue arrays follow a first-in-first-out approach, so elements that are first stored in the queue are removed/accessed first(enqueue operations add elements at the rear of the queue array).

The following operations leave 10 elements in the queue of array size 12 after its done:

10 enqueue operations= adds 10 elements

5 dequeue operations= removes 5 elements( 5 elements left in queue)

6 enqueue operations= adds 6 elements(11 elements in queue)

10 dequeue operations= removes 10 elements(1 element left in queue)

8 enqueue operations= adds 8 elements(9 elements in queue)

2 dequeue operations= removes 2 elements(7 elements left in queue)

3 enqueue operations= adds 3 elements(10 elements in queue)

Therefore there are 10 elements in the queue after enqueue and dequeue operations.

8 0
3 years ago
____ is a broadband wireless transmission technology that is based upon a series of IEEE standards.​
dedylja [7]

Answer:

"WiMAX" is the correct answer for the above question.

Explanation:

  • WiMAX is a broadband wireless technology that follows the IEEE standard. This full form of this technology is "Worldwide Interoperability for Microwave Access".
  • This technology is used to control the media and provide the physical layer.
  • The above question asked about the term which follows the IEEE standard. So the term is "Wimax"

3 0
4 years ago
Other questions:
  • Because of the limited storage capacity of __________, it is unsafe to talk on a cell phone while driving on a freeway during ru
    7·1 answer
  • Create a stack with three integers and then use .toarray to copy it to an array.
    10·1 answer
  • Write a c++ function, largestnum, that takes as parameters a double array and its size and returns the index of the last occurre
    14·1 answer
  • I just want to ask if some one know an online school program that offer a live session and the cost of it not to expensive. for
    10·1 answer
  • -..
    11·1 answer
  • If you receive an email message you suspect is spam, what should you do?
    11·1 answer
  • Sally is editing her science report about living things. She needs to copy a paragraph from her original report.
    13·1 answer
  • PLEASE FASTTTTT
    8·2 answers
  • Unit: Advanced Productivity Applications This activity will help you meet these educational goals: Content Knowledge—You will us
    8·1 answer
  • What is a reason for zipping a file?A. to encrypt themB. to return them to their original sizeC. so they display properly on a W
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!