Question: #======================================= AWK programming language Use Linux terminal and Vim #================================= BEGIN{TOT=0; } { TOT=TOT+$1; #add field one of each record to TOT next; } END{print
#=======================================
AWK programming language
Use Linux terminal and Vim
#=================================
BEGIN{TOT=0; } { TOT=TOT+$1; #add field one of each record to TOT next; } END{print TOT; }
#===============================
BEGIN{ } { Tot=$1 + $2 + $3 print $0,":",Tot } END{ }
#======================================
BEGIN{TOT=0; }
/PATTERN/ { #PATTERN can be a regular expression printf "PATTERN "; #Do nothing(in this script, the literal string:PATTERN, won't be found #just showing the pattern matching syntax) next; }
# since there is no pattern on the next section, it will operate on every line
{ TOT=TOT+$1; #add field one of each record to TOT next; }
END{print TOT; }
#==========================================
Using the above examples of awk programs, do the followings two questions.
Questions 1 Write your own awk script, my_script.awk, that will total the rows and columns of an input file. Showing all lines with row totals on right and column totals at bottom. And grand total below the row totals to the right of the column totals. Formatting is recommended so that the integers. line up well.
Question 2 Create a data file: data.txt, that has at least ten rows of 3 space-separated integers in each row.
Run your awk script with your data file cat data.txt | awk -f my_script.awk
Make sure your script is well indented and commented. Upload a screen shot of the run, your data file and your awk script, named: my_script.awk
#========================================================================
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
