Explanation: The sort command is used to sort the lines of a text file or the output of another command in alphabetical, numerical, or other order. The sort command has the following syntax: sort [options] [file…]. The file argument is the name of one or more files to be sorted. If no file is given, the sort command reads from the standard input, which is usually the keyboard or the output of another command.
The | (pipe) symbol is used to connect the output of one command to the input of another command. This allows the creation of pipelines of commands that process data sequentially. The pipe symbol has the following syntax: command1 | command2. The command1 argument is the name of the first command, whose output is sent to the input of the second command. The command2 argument is the name of the second command, which receives the output of the first command as its input.
Therefore, the command export-logs | sort sorts the output of the export-logs command in alphabetical order. The export-logs command is assumed to be a custom command that exports some logs to the standard output. The sort command receives the output of the export-logs command as its input and sorts it according to the default criteria, which is the first character of each line. The sorted output is then displayed on the screen or can be redirected to a file or another command.
The other options in the question are incorrect because they use the wrong symbols to connect the commands. The < (input redirection) symbol is used to read the input of a command from a file instead of the keyboard. The > (output redirection) symbol is used to write the output of a command to a file instead of the screen. The & (background) symbol is used to run a command in the background, which means the command does not wait for user input and allows the user to run other commands simultaneously. The <> (bidirectional redirection) symbol is used to read and write the input and output of a command from and to the same file. None of these symbols can be used to sort the output of the export-logs command. References:
- Linux Essentials Version 1.6 Objectives: 3.2. Searching and Extracting Data from Files1
- Linux Essentials Version 1.6 Exam Study Resources: Linux Essentials Manual - Chapter 9. The Power of the Command Line - 9.2. Searching and Extracting Data from Files - 9.2.1. The sort Command2
- Linux Essentials Version 1.6 Exam Study Resources: Linux Essentials Manual - Chapter 9. The Power of the Command Line - 9.3. Turning Commands into a Script - 9.3.1. Pipes and Redirection2
- Linux Essentials Version 1.6 Exam Study Resources: Linux Essentials Manual - Appendix A. Answers to the Exercises - Chapter 9. The Power of the Command Line - 9.2. Searching and Extracting Data from Files - Exercise 9.2.12
- Linux Essentials Version 1.6 Exam Study Resources: Linux Essentials Manual - Appendix A. Answers to the Exercises - Chapter 9. The Power of the Command Line - 9.3. Turning Commands into a Script - Exercise 9.3.12