Question 280
A technician working on a classroom Linux system finds: A learner sorts a list of names but mistakenly expects sort to remove duplicate entries automatically. Which command or choice meets the stated need?
Explanation
Correct Answer
Use sort followed by uniq when adjacent duplicate lines should be collapsed, or use sort -u when available. This directly addresses the reported situation. Why it works: sort orders records but does not ordinarily remove duplicates; uniq removes repeated neighboring lines. Acceptance evidence: A fixture with repeated unsorted names produces one occurrence of each unique name.
Incorrect Answers
This option would change the part of the system described by: Use tail -n 20 application.log to show the newest twenty available lines. The reported behavior instead arises because use sort followed by uniq when adjacent duplicate lines should be collapsed, or use sort -u when available. The direct remediation is “Use sort followed by uniq when adjacent duplicate lines should be collapsed, or use sort -u when available”.
Use grep 'ERROR' access.log to select lines containing the literal search term. That explains why “Use grep 'ERROR' access.log to select lines containing the literal search term” is useful for its own dependency, but the present failure follows a different constraint: Use sort followed by uniq when adjacent duplicate lines should be collapsed, or use sort -u when available. The targeted correction is “Use sort followed by uniq when adjacent duplicate lines should be collapsed, or use sort -u when available”.
“Use the append redirect >> when previous results must be retained, after inspecting the target file” acts on a neighboring technical dependency: Use the append redirect >> when previous results must be retained, after inspecting the target file. It does not resolve the stated condition, whose causal mechanism is: Use sort followed by uniq when adjacent duplicate lines should be collapsed, or use sort -u when available. The required action is “Use sort followed by uniq when adjacent duplicate lines should be collapsed, or use sort -u when available”.