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
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
- 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, youll need to use a temporary variable. 
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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
