Question
1) Assume h1.awk is located at the current working directory. $ cat h1.awk NR>=2&&NR $ awk -f h1.awk float Output: Function: 2) $ awk '{print
1) Assume "h1.awk" is located at the current working directory.
$ cat h1.awk
NR>=2&&NR
$ awk -f h1.awk float
Output:
Function:
2) $ awk '{print $1, $NF }' float
Output:
Function:
3) Assume "h2.awk" is located at the current working directory.
$ cat h2.awk
BEGIN { print "Start to scan file"}
{print NR NF}
END { print "END", FILENAME }
$ awk -f h2.awk float
Output:
Function:
4) $ sed 's/[^,]*,//g' float
Output:
Function:
5) $ ls *.awk | awk '{ print "cp -r" $1 " " $1 ".new" }' |sh
(Hint: sh file runs file as a shell script. Use ls to discover the changes in your working directory)
Output:
Function:
6) $ mkdir test1 test2 test3
$ ls -l | grep '^d' | awk '{print "mv -r " $9 " " $9 ".new"}' | sh
(Hint: use ls to discover the changes in your working directory)
Output:
Function:
Part III: Write down the output of the last command in each question and describe the function of it. Note: please do not simply say awk executes the commands from a file. Question 1) to 4) are processing the same text file "float". "float" has a content shown as in the table below. To try those commands in the questions, you can create your own "float" file in your Ubuntu system Wish I was floating in blue across the sky, my imagination is strong, And I often visit the days When everything seemed so clear. Now I wonder what I'm doing here at all. Hint: you may need to create "hl.awk" and "h2.awk" in your own computer by yourself
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started