Question

In: Computer Science

3) Write the awk command that would show the user wmorales (or yourself) that is online...

3) Write the awk command that would show the user wmorales (or yourself) that is online (you have to use a pipe) Output, depending on the system that you are using or the command to find the users online, but it would be similar to:

wmorales pts/37 10.32.9.93 13:58 1.00s 0.15s 0.10s w

or

wmorales pts/8 2020-04-25 12:22 (c-71-59-237-122.hsd1.or.comcast.net)

YOUR AWK COMMAND:

(10 points hard one) -

4) use who to show the the users on our system that have the letter r in their first name, OR last name, but nowhere else. Note also that the r can be r or R. Note that your output will be a bit different as well, but note that the uses listed do have r either on their first or last name

output would be similar to:

Outcyrus.rice pts/21 2017-10-23 12:38 (jamess-iphone-2.wifi.pcc.edu)

tina.olsgaard pts/29 2017-10-23 12:41 (174-25-110-78.ptld.qwest.net)

rachel.benes pts/30 2017-10-23 12:54 (laptop-2j35sntl.wifi.pcc.edu)

rachel.benes pts/33 2017-10-23 13:43 (laptop-2j35sntl.wifi.pcc.edu)

jarod.morrow pts/35 2017-10-23 12:54 (sytc310-08.ad.pcc.edu)

wmorales pts/37 2017-10-23 13:58 (10.32.9.93)

----------------------- cut ------------------

note: the letter r or R has to appear either in their first name or last name only, not on the name of the machine that they are using if it happen to have r in it.

YOUR AWK COMMAND:

5) (3 points - easy) from the file called winelist extract a list of wines that cost less than $7.00 output (

it may be different depending the time you do it):

1977 6.99 Franciscan

1977 6.75 Alexander Valley

1977 5.99 Charles Krug

YOUR AWK COMMAND:

Solutions

Expert Solution

SOLUTION:

The Following solution has been implemented on an Ubuntu Linux Box installed on VMware Workstation.

For the purpose of implementation, the following users have been created, in addition to the root User.

1. wmorales

2. Rambo

3. arun

4. danny

Also a file “winelist” has been created containing a list of wines in the prescribed format for Question 5.

Question 3: Write the awk command that would show the user wmorales (or yourself) that is online.

Use the following command,

who | awk ‘/wmorales/ {print}’

Note:

1. The who command displays the users currently logged in.

2. The Pipe ( | ) symbol is used to pass on the output of “who” as input to the next command “awk”.

3. The ‘/wmorales/’ part of the awk command is a pattern match for the word wmorales.

4. The {print} command part of awk is responsible for printing the filtered output.

Question 4: Show the users on our system that have the letter r in their first name, OR last name, but nowhere else. Note also that the r can be r or R.

Use the following command,

                    who | awk ‘$1 ~ /[Rr]/ {print}’

         

Note:

1. The who command displays the users currently logged in.

2. The Pipe ( | ) symbol is used to pass on the output of “who” as input to the next command “awk”.

3. The ‘$1’ instructs only the first column should be searched for matches according to pattern.

4. The ‘~’ symbol is used for pattern matching. Here the ‘[Rr]’ indicates that the matching can be either ‘R’ or ‘r’.

5. The {print} command part of awk is responsible for printing the filtered output.

Question 5: From the file called winelist extract a list of wines that cost less than $7.00.

Use the following command,

cat winelist | awk -F ‘ ‘ ‘$2<7.00’

Note:

1. The “cat” command prints the contents of the file “winelist”.

2. The Pipe ( | ) symbol is used to pass on the output of “cat” command as input to the next command “awk”.

3. The “ -F ‘ ‘ “ part of the command is used to specify a delimiter using which you can process specific columns. Here the delimiter is “single space”.

4. The ‘$2<7.00’ part accesses the second column and checks if the value is less than 7.00.

5. The {print} command part of awk is responsible for printing the filtered output.

Hope this helps. Kindly get back to me for clarifications if any.


Related Solutions

write an awk script that works as wc command.
write an awk script that works as wc command.
**Need to use awk command in putty (should be a ONE LINE COMMAND) Write the command...
**Need to use awk command in putty (should be a ONE LINE COMMAND) Write the command that would find all lines that have an email address and place a label email = before the line in the file longfile output will multiple lines similar to this one : using a good awk command the output would be something like this email = From: "Linder, Jann/WDC" <[email protected]> email = To: Mr Arlington Hewes <[email protected]> email = > From: Mr Arlington Hewes...
Convert the following code from awk to Perl: (please don't use a2p (awk to perl) command)...
Convert the following code from awk to Perl: (please don't use a2p (awk to perl) command) Here was the original problem: Calculate the grade for each student that appears in the data file. You may calculate the grade based on total earned points, divided by total possible points. Or, for 10 points extra credit; Use the weighted totals for this course; available in the syllabus and on the course home page. Output a list of students, their grade as a...
Write a Java program that allows the user to specify a file name on the command...
Write a Java program that allows the user to specify a file name on the command line and prints the number of characters, words, lines, average number of words per line, and average number of characters per word in that file. If the user does not specify any file name, then prompt the user for the name.
Put yourself in the shoes of the hiring manager, and research yourself in every online format...
Put yourself in the shoes of the hiring manager, and research yourself in every online format that you can access. Google your name. What is out there in cyberspace that may prevent a potential employer from extending an offer to you? Post strategies you can offer to address/correct information that is associated with your name/likeness, such as images, on the internet.
1 . Set-User mjordan–MobilePhone “(808) 555-1234” and Research online the other command parameters to see how...
1 . Set-User mjordan–MobilePhone “(808) 555-1234” and Research online the other command parameters to see how else you could update contact information using the EMS. 2.What do we use the PIPE command for? What is it’s purpose?   explain in your own words what the PIPE command does for us in scripting. 3.Why would organizations mail-enable public folders? 4. What command would grant Anonymous Contributor access to the \Sales public folder 5.How are In-place archives different than PST files? 6.If you...
Create a python program that will: prompt a user for a command Command get_data Level 1:...
Create a python program that will: prompt a user for a command Command get_data Level 1: Take one of the commands my_max my_min my_range my_sum mean median mode fib factorize prime Requirements: Your commands should be case-insensitive You should use python lists to store data You should NOT use built-in python math functions, or math libraries to compute these values Tips: Write one function that will convert a string with comma-separated numbers into a python list with the numbers. You...
When logged in as the root user, how often would you do the command rm -rf...
When logged in as the root user, how often would you do the command rm -rf / ?
Write an advertisement for a user support position. Find one or more ads online or in...
Write an advertisement for a user support position. Find one or more ads online or in your local newspaper for information technology and user support positions. Note the format and content of a typical help wanted ad in the IT field. Select one of the user support position descriptions in Chapter 1, and then write a classified ad that could be used to attract job applicants for the position whose description you selected.
unix question please write a program and then show how to use top command that shows...
unix question please write a program and then show how to use top command that shows the zombie process, give snapshot of top command that shows the zombie process Write a very simple program that will show the possibility of having zombie processes. Write a program named zombie.c The main process will create a child. The child prints something like: “I am the child with pid ….. and my parent has ppid ….” Next, the child will sleep for 1...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT