Difficulty: Easy
Correct Answer: sort -r
Explanation:
Introduction / Context:
Sorting text data is fundamental in log analysis, report generation, and data cleaning. The standard 'sort' utility can order lines lexicographically or numerically, and supports reversing the order with a simple switch for quick, scriptable transformations.
Given Data / Assumptions:
Concept / Approach:
'sort -r file' outputs the same lines in descending order. Combine with '-n' for numeric reverse order ('sort -nr'), or specify keys with '-k' for column-based sorts. Piping from another command is common in Unix pipelines to reverse-stream data on the fly.
Step-by-Step Solution:
Verification / Alternative check:
Compare 'sort file' vs 'sort -r file' outputs to confirm reversed ordering. For numbers, add '-n' and verify correct numeric treatment rather than string ordering.
Why Other Options Are Wrong:
Common Pitfalls:
Forgetting '-n' for numeric data, locale-collation surprises, or neglecting '-k' when sorting on specific fields.
Final Answer:
sort -r
Discussion & Comments