nerdexam
LPI

010-160 · Question #21

Which of the following commands sorts the output of the command export-logs?

The correct answer is D. export-logs | sort. The pipe operator (|) chains commands by sending the stdout of one command as stdin to the next, enabling output sorting.

The Power of the Command Line

Question

Which of the following commands sorts the output of the command export-logs?

Options

  • Aexport-logs < sort
  • Bexport-logs > sort
  • Cexport-logs & sort
  • Dexport-logs | sort
  • Eexport-logs <> sort

How the community answered

(36 responses)
  • A
    3% (1)
  • C
    3% (1)
  • D
    94% (34)

Why each option

The pipe operator (|) chains commands by sending the stdout of one command as stdin to the next, enabling output sorting.

Aexport-logs < sort

The < operator redirects a file as input to a command; it cannot redirect one command's output into another command.

Bexport-logs > sort

The > operator redirects a command's output to a file named 'sort', not to the sort utility itself.

Cexport-logs & sort

The & operator runs export-logs in the background and then runs sort independently, with no data connection between the two processes.

Dexport-logs | sortCorrect

The pipe operator | sends the standard output of export-logs directly to the sort utility as standard input, allowing sort to process and alphabetically order the results. This is the standard Unix/Linux mechanism for chaining command output through filters like sort, grep, or awk without intermediate files.

Eexport-logs <> sort

The <> operator opens a file descriptor for both reading and writing simultaneously; it is not used to chain two commands together.

Concept tested: Unix pipe operator for command output chaining

Source: https://www.gnu.org/software/bash/manual/bash.html#Pipelines

Topics

#pipes#shell operators#redirection#command chaining

Community Discussion

No community discussion yet for this question.

Full 010-160 Practice