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

# Figure 1 cat exam1.data Traverse City city Iron Mountain city Pleasant Plains

ID: 3755441 • Letter: #

Question

# Figure 1 cat exam1.data Traverse City city Iron Mountain city Pleasant Plains township Green Lake township South Haven city Ellsworth township Holland city Carp Lake township Grand Traverse Dickinson Lake Grand Traverse Allegan Lake Allegarn Emmet 14482 7624 1581 5784 3 817 7016 759 1. Consider the Linux commands shown in Figure 1. What will be displayed if the command given below is entered at the next shell prompt? sort -t''-k2,2 -k1,1r exam1.datahead -1 7016 817 A) Holland city B) Ellsworth township C) South Haven city D) Pleasant Plains township E) None of the above Allegan Lake Allegan Lake 1581 02. Consider the Linux commands shown in Figure 1. What will be displayed if the command given below is entered at the next shell prompt? grep " Lake" exam1.data sort -t' ' -k3,3 head -1 A) Pleasant Plains township B) Green Lake township C) Ellsworth township D) Carp Lake township E) None of the above Lake Grand Traverse Lake Emmet 1581 5784 817 759

Explanation / Answer

Sort is a command to arrange the column in ascending or descending order

-t is a delimiter to provide a tab space for the columns

'|' the symbol within single quotes will be printed as such

'-k' - means key, based on which the sorting will be done. The format is '-km,n' where m is the starting key and n is the ending key so -k2,2 means it will consider 2nd column. (Example: -k1,2 means starting key is the 1st column and ending key is the 2nd column

r is used to reverse the result (ie) it will print in descending order

Thus for -k1,1r, will consider the first column as a key column to sort and the first column will be printed in the descending order.

head -1 - will print the top 1st column

thus the answer for the first question is .

sort -t'I' -k2,2 -k1,1r exam1.data I head

sort -t'I' - will display a tab space and to print | in between the columns

-k2,2 - will consider the 2ds column as key and sort in ascending order

The result of that table will be (the second column is sorted in ascending order. this will not be displayed. I have just showing it for understanding purpose)

-k1,1r - Now the key is the first column and it will be reversed that is 1st column is sorted in descending order. The first column will be sorted in descending order as shown

head -1 will consider the top first column which is highlighted in bold.

The tp first column is

which is not listed in Option A, B, C and D

Thus Option E is the answer

Note: The question is based on the 1st and 2nd column. so I have not shown the third column in the example

Traverse city city Allegan Iron mountain city Allegan Pleasant plains township Dickinson Green Lake Township Emment South Haven City Grand Traverse Ellsworth Township Grand Holland city Lake Carp Lake Township Lake