References:
Create a two-column data file, called file.dat with x-y coordinates of several points (using emacs or cat). With awk, find the product x*y of for each line in your datafile:
awk '{print $1*$2}' file.dat
Explore some of the possible numerical operations of awk by trying to
use sin, cos, exp, log, functions (e.g., cos($1+$2)).
The single quotes around the first argument are needed so that the shell does not change anything before it passes the argument string to awk.
Awk's second argument, the filename, tells awk where to get standard input. If the second argument is not present, awk expects input from the keyboard. Use awk with only one argument to find the product 0.12345679*9. Try this by using the "$1*$2" form above; you'll have to type in the numbers, separated by a space, then hit C-d (control-d) to signal to awk that you are done giving input. Then open the exercise answer file lab02 in an emacs window, type "Exercise 1" and cut and paste this last awk session (the command line, your typing, and the result) from your xterm window into the exercise answer file.
You can use awk as a simple calculator as follows:
awk 'BEGIN{print sin(4*3.14159265/3);}'
With the BEGIN in this case, awk is not expected to process any input. It just evaluates the expression and quits. Try it.
When you are satisfied with your result, copy your modified code to the exercise answer file under the header "Exercise 3" and submit it.