Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question_2: Explain briefly what do the following awk commands do: ) awk \'$0 !~

ID: 3594172 • Letter: Q

Question

Question_2: Explain briefly what do the following awk commands do:

) awk '$0 !~ /^$/' file
) awk '$2 ~ /^[JT]/ {print $3}' file
c) awk '$2 !~ /[Mm]isc/ {print $3 + $4}' file
d) awk '$2 ~ /John|Fred/ {print $0}' file
e) awk 'END{print NR}' file
f) awk '{ print $NF }' file
g) awk 'NF > 4' file
h) awk '{print $2, $1}' file
i) awk -F: '$1 ~ /^....$/ {print $3, $1}' file
j) The command ps -ef displays all Linux processes.
Use awk and other Linux utilities to display all PIDs on screen without the header label "PID".
k) Using awk, write a command to display fields 1 and 5 from file /etc/passwd.

Explanation / Answer

a) print the lines whose first word in not empty (print all non empty lines)

b) prints the third word (field) of the lines whose second word starts with J or T

c) prints the addition of third and fourth fields of each line whose second field does not match Misc or misc

d) prints the whole line whose second field is John or Fred

e) Counts the lines in a file

f) print the last word of each line from the file

g) print the lines containing more than 4 words

h) prints the second and first word of each line from the file

i)

j)

k) awk '{print $1,$5}' /etc/passwd

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote