Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 4 (6 points): Answer the following questions about AWK: a) What is AWK,

ID: 3852757 • Letter: P

Question

Problem 4 (6 points): Answer the following questions about AWK:

a) What is AWK, and why is it useful? b) Assume you have a file called ‘calculate.awk’ containing AWK commands. Give the command for running all of the commands in this file. c) Give AWK commands for accomplishing each of the following: - Print the 2nd last field (the field directly before the last field) of each line from a file named ‘last.txt’

THE AWK PROGRAMMING SYSTEM Problem 4 (6 points): Answer the following questions about AWK: a) What is AWK, and why is it useful? b) Assume you have a file called 'calculate.awk containing AWK commands. Give the command for running all of the commands in this file. for running all of the co c) Give AWK commands for accomplishing each of the following: Print the 2nd last field (the field directly before the last field) of each line from a file named ‘last.txt, +' Assume you have a file called ‘names, that contains a list of people, one person per line. Also assume that on each line, the 3rd field on that line contains the age of the person. Some of the people do not have an age listed, and those lines only have 1 field. Print the total age for all the people that have an age (the sum of all of their ages). Print the total number of lines from a file named 'lines' Exchange the second and the third fields of every line, and then print the lines (you can print each line directly after the exchange). After printing all of the lines, print out the message "Done!". Assume the file name is ‘switch.txt. + HINT: To switch the two fields around, you'll need to use a temporary variable. 4

Explanation / Answer

a)

b)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote