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

QUESTION 1 Copy file called sortfile from my home directory. The file contains t

ID: 3803833 • Letter: Q

Question

QUESTION 1

Copy file called sortfile from my home directory. The file contains three columns of information : username, uid number and group name respectively, separated by a field separator.

Will the following command sort the file on the group name field?

sort -t! -k3 sortfile

Yes

No

QUESTION 2

Copy the file called sortfile from my home directory. The file contains three columns of information : username, uid number and group name respectively, separated by a field separator.

The following command will reverse sort the the file numerically on the uid.

sort -t! -k2rn sortfile

True

False

QUESTION 3

Create a sort command string that will numerically sort the file called /etc/group on the GID field (3rd field).

Complete the command string below to meet the above statement.

sort -t: -### /etc/group

Replace the ## with the correct characters to complete the commmand string.

Provide ONLY the characters that replace the ## in your answer.

QUESTION 4

cd to my home directory.

Execute the command: ls -l | sort -k5n

This command will sort the ouput of the ls command by the file size and list the largest file last.

True

False

Explanation / Answer

Answer: See the answers below:

Q 1. True

Option k is used to specify the key to be used to sort the file. In this case, it is 3 which represents the third field in file i.e. group name. Hence, it will sort the file based on group name.

Q 2. True

Option 'r' is used to reverse the results of comparison, while option n is used to compare as per numerical value of string.

Q 3. sort -t: -k3 # /etc/group

Option k is used to specify the key based on which sorting is to be done. Next character 3 (3rd field in file) specifies the value of option k.

Q 4. False

It will not list the largest file first. For reverse sorting, option r is to be used.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote