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
TWO QUICK QUESTIONS
andrezito [222]
I'm guessing 8? But I'm not 100% positive 
5 0
4 years ago
What is the initial condition in this set of code?
marissa [1.9K]

Answer:An initial condition is an extra bit of information about a differential equation that tells you the value of the function at a particular point. Differential equations with initial conditions are commonly called initial value problems.

The video above uses the example

{

d

y

d

x

=

cos

(

x

)

y

(

0

)

=

−

1

to illustrate a simple initial value problem. Solving the differential equation without the initial condition gives you  

y

=

sin

(

x

)

+

C

.

Once you get the general solution, you can use the initial value to find a particular solution which satisfies the problem. In this case, plugging in  

0

for  

x

and  

−

1

for  

y

gives us  

−

1

=

C

, meaning that the particular solution must be  

y

=

sin

(

x

)

−

1

.

So the general way to solve initial value problems is: - First, find the general solution while ignoring the initial condition. - Then, use the initial condition to plug in values and find a particular solution.

Two additional things to keep in mind: First, the initial value doesn't necessarily have to just be  

y

-values. Higher-order equations might have an initial value for both  

y

and  

y

′

, for example.

Second, an initial value problem doesn't always have a unique solution. It's possible for an initial value problem to have multiple solutions, or even no solution at all.

Explanation:

5 0
3 years ago
each term to the appropriate definition. DBMS data mining hash file index key field locking protocol relation roll back schema S
ikadub [295]

Answer:

1. DBMS

C. <em>A storage system that provides efficient access to randomly chosen items</em>

G. <em>Performs database operations requested by application software</em>

2. data mining

B. <em>The process of extracting hidden information</em>

3. hash file

A. <em>A. means of locating a particular record within a file</em>

4. index key field

F. <em>An item used to identify records uniquely</em>

5. locking protocol

E. <em>A system to guard against database errors due to performing transactions concurrently</em>

6. relation

D. <em>A structural unit (with rows and columns) in a popular database model</em>

7. roll back schema

I. <em>A "road map" of a particular database's design</em>

J. <em>To "unwind" a transaction</em>

8. SQL

H. <em>A popular language that implements relational database operations.</em>

5 0
3 years ago
AD and BC are equal perpendiculars to a line segment AB (see figure). Show that CD
Simora [160]
Show the picture to answer the question
7 0
3 years ago
A computer network is a collection of _____.
Talja [164]
Wifi..............????
6 0
3 years ago
Read 2 more answers
Other questions:
  • A boolean variable named rsvp an int variable named selection, where 1 represents "beef", 2 represents "chicken", 3 represents "
    14·1 answer
  • What is TRUE about the following array?
    15·1 answer
  • The _________ indicates the number of elements, or values, an array can hold
    14·1 answer
  • Instructions:Select the correct answer.
    8·2 answers
  • 6. What is the difference between portrait and landscape orientation? What are the advantages of
    9·1 answer
  • Discuss what repetitions structures are, and how they differ from the vectorization approaches we have previously studied in the
    10·1 answer
  • Describe the different non-printing characters,​
    11·1 answer
  • 1. What does a computer
    7·2 answers
  • What are the small squares that appear in the corners and in the middle of the sides of a selected object's border called?
    7·1 answer
  • The designers of a database typically begin by developing a​ __________ to construct a logical representation of the database be
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!