Question: Hello, I have an awk command Unix assignment and need some help, please. Also, could you please explain the steps? Thanks! 1) Write an awk

Hello, I have an awk command Unix assignment and need some help, please. Also, could you please explain the steps? Thanks!

1) Write an awk script that will output the line numbers of each record that has less than or equal to 4 fields.

Input file (hw01.csv):

1,3,5,8,10,11,54

1,2,3,4

15,18,21,42,37

1,1,1,0,0,3,16

4,1,8,0,4,6,13,16,17,20,8,6,4

13

Example output:

2

6

2) Write an awk script that will output the most popular dog breed based on number of votes using the information from the following entirely unbiased survey.

Input file (hw02.csv):

Breed, Votes

Black Lab, 30

Chihuahua, 2

Pug, 1

Corgi, 45

Shar Pei, 21

Shih Tzu, 5

Maltese, 7

Expected output:

Corgi has 45 votes

3) Write an awk script that will output the records that contain only letters.

Input file (hw03):

Avengers: Endgame

Star Wars: Episode 7 - The Force Awakens

The Great Gatsby

Furious 7

Avengers: Infinity War

Frozen 2

Harry Potter and the Deathly Hallows: Part 2

Lion King 1

The Fate of the Furious

Minions

Iron Man 3

Expected output:

Avengers: Endgame

The Great Gatsby

Avengers: Infinity War

The Fate of the Furious

Minions

4) Write an awk script that will output the sum of all the sales figures.

Input file (hw04.csv):

Name,Emp ID,Sales,Dept,Resi

Andrew,24,88,Eng,Y

Brandon,66,14,Mkt,Y

Chelsey,8,,Eng,N

Deborah,38,,Ift,Y

Erik,32,13,Mkt,N

Arielle,13,48,Eng,N

Shaun,55,78,Ift,N

Ninette,3,24,Opr,Y

Nguyen,10,54,Eng,Y

Expected output:

SUM: 319

5) Write an awk script that will output the average of all the sales figures.

Input file (hw04.csv):

Name,Emp ID,Sales,Dept,Resi

Andrew,24,88,Eng,Y

Brandon,66,14,Mkt,Y

Chelsey,8,,Eng,N

Deborah,38,,Ift,Y

Erik,32,13,Mkt,N

Arielle,13,48,Eng,N

Shaun,55,78,Ift,N

Ninette,3,24,Opr,Y

Nguyen,10,54,Eng,Y

Example output:

AVG: 35.4444

Thanks again!!

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!