nerdexam
LPI

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.

The Power of the Command Line

Question

Which of the following commands puts the lines of the file data.csv into alphabetical order?

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)
  • A
    2% (1)
  • B
    89% (42)
  • C
    2% (1)
  • E
    6% (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.

Aa..z data.csv

`a..z` is not a valid Linux command.

Bsort data.csvCorrect

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.

Cabc data.csv

`abc` is not a valid Linux command.

Dwc -s data.csv

`wc` counts words, lines, or characters in a file and the `-s` flag does not exist for sorting.

Egrep --sort data.csv

`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

#sort command#text processing#file sorting

Community Discussion

No community discussion yet for this question.

Full 010-160 Practice