Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Module 4 : awk All steps should be done using one command line and the awk utility. Don't use any other filter such as cut,

Module 4: awk
All steps should be done using one command line and the awk utility. Don't use any other filter such as cut, grep, etc.
Comparing awk with sed by doing the same first 6 steps but using awk:
1. Without naming the continent, write an awk command line that has the same output as:
head -6 lab3in | tail -2
2. Without using line numbers, write an awk command line that has the same output as: grep America lab3in
3. Without using line numbers, write an awk command line that has the same output as: wc l < lab3in
4. Without using line numbers, write an awk command line that has the same output as: grep -v '^$' lab3in
5. Without using line numbers, print only the lines with continent data, indenting each line by 3 spaces.
6. Without using line numbers, print the continent names and areas, separated by colon (:).
Only the continent names and their areas should be printed.
7. Comparing your 6 answers above between sed and awk, you can see that sometimes the sed command line is
shorter, and sometimes awk is shorter.
a. Use the echo command to show which step is shorter with sed, and which steps are shorter with awk
b. It would be difficult to do all of step 7 of Lab 3 with awk.
Use the echo command to show which part of step 7 of module 3 lab is difficult to do with awk.
Now we look at more complicated tasks where awk would be simpler to use than sed.
For the steps below youll write awk scripts.
To document each step in your answer file:
- If you use the script utility to record your answer:
-- Use the cat command to display your awk script
-- Then run the awk script to produce the output
- If you dont use the script utility to record your answer:
-- copy your awk script to the output file
-- run the awk script to produce the output
-- copy and paste both the awk command line and the output
8. Using data from the /etc/passwd file, print the following information about yourself, with a text explanation:
User FULL NAME is on line N out of M lines
where FULL NAME is your name as it appears in the /etc/passwd file, N is the line number that contains your
information, and M is the total number of lines.
9. Print the name of the file in the root directory that has the largest size.
10. Start from the who command output (dont use any option of who), print the number of users who log in more than
once. When printing the number, print an explanation text that corresponds to the number of users.
Example output: 1 user logging in more than once
or 3 users logging in more than once
or no user logging in more than once
Note that there is no 's' after 'user' when it's 1 user or no user, but there is 's' when its 2 or more users.
Note also that no user must be printed, not 0 user.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions

Question

Does it avoid using personal pronouns (such as I and me)?

Answered: 1 week ago

Question

Does it clearly identify what you have done and accomplished?

Answered: 1 week ago