Question 300
A command's error diagnostics must be saved in errors.txt while normal output remains visible. One student proposes Run command 2> errors.txt and another proposes Run sort names.txt. Which technical comparison is the soundest?
Explanation
Correct Answer
Correct distinction: Run command 2> errors.txt targets redirect error stream separately; File descriptor 2 is standard error and 2> redirects it independently of stdout. The compared alternative instead serves sort text lines.
Incorrect Answers
Incorrect mapping: Run sort names.txt is used for sort text lines. It does not displace Run command 2> errors.txt for the described requirement.
The mechanisms are different: File descriptor 2 is standard error and 2> redirects it independently of stdout. By contrast, sort orders input lines according to the active locale's collation rules. They are not universally interchangeable.
The third option addresses count input lines: wc -l counts newline characters, commonly used to count complete lines. The original action remains relevant because File descriptor 2 is standard error and 2> redirects it independently of stdout.