3. Which of the following commands sorts the output of the command export-logs?
Answer: D
export-logs | sort
The command that sorts the output of the command export-logs is export-logs | sort. This syntax utilizes a pipe to send the output of export-logs directly into the sort command for sorting.
A) export-logs < sort
This option incorrectly suggests that the sort command takes input from export-logs. The use of '
B) export-logs > sort
This choice implies that the output of export-logs is being redirected to a file named 'sort', which does not sort the output but rather saves it to a file instead. Thus, it fails to achieve the intended sorting.
C) export-logs & sort
Using '&' indicates that the commands would run simultaneously in the background. This does not facilitate sorting the output of export-logs, as it does not connect the two commands in a way that allows for sorting.
D) export-logs | sort
This option is correct as it utilizes the pipe operator '|', which takes the output from export-logs and feeds it directly to the sort command, thus achieving the desired sorting of the output.
E) export-logs > sort
This option is a repeat of choice B and similarly indicates that the output of export-logs is redirected to a file named 'sort', rather than sorting the output. Therefore, it does not fulfill the requirement of sorting.
Conclusion
The correct command for sorting the output of export-logs is export-logs | sort, as it effectively uses the pipe operator to connect the two commands. All other options fail to achieve sorting either by misusing redirection or by not properly linking the commands. Thus, option D stands out as the only correct solution.