010-160 · Question #89
Which of the following commands puts the lines of the file data.csv into alphabetical order?
The correct answer is B. sort data.csv. The sort command in Linux reads lines from a file and outputs them in alphabetical order by default. No other listed command performs this function.
Question
Options
- Aa..z data.csv
- Bsort data.csv
- Cabc data.csv
- Dwc -s data.csv
- Egrep --sort data.csv
How the community answered
(47 responses)- A2% (1)
- B89% (42)
- C2% (1)
- E6% (3)
Why each option
The `sort` command in Linux reads lines from a file and outputs them in alphabetical order by default. No other listed command performs this function.
`a..z` is not a valid Linux command.
The `sort` command is a standard Unix/Linux utility that reads lines from a specified file and writes them to standard output in sorted order. By default it sorts lexicographically (alphabetically), making `sort data.csv` the correct command for this task.
`abc` is not a valid Linux command.
`wc` counts words, lines, or characters in a file and the `-s` flag does not exist for sorting.
`grep` searches for patterns within files and has no `--sort` option.
Concept tested: Linux sort command for ordering file content
Source: https://www.gnu.org/software/coreutils/manual/html_node/sort-invocation.html
Topics
Community Discussion
No community discussion yet for this question.