nerdexam
CompTIA

LX0-103 · Question #193

For which of the following can the tee command be used?

The correct answer is E. Send a command's output to stdout and a to file at the same time.. The tee command reads from stdin and writes simultaneously to stdout and one or more files, making it useful for logging output while still displaying it on screen.

GNU and Unix Commands

Question

For which of the following can the tee command be used?

Options

  • APrint the contents of a file in reverse order.
  • BUse the output of one command as arguments to another.
  • CAdd line numbers to the output of a command.
  • DPipe the output of one command into the input of another.
  • ESend a command's output to stdout and a to file at the same time.

How the community answered

(23 responses)
  • A
    9% (2)
  • C
    4% (1)
  • E
    87% (20)

Why each option

The tee command reads from stdin and writes simultaneously to stdout and one or more files, making it useful for logging output while still displaying it on screen.

APrint the contents of a file in reverse order.

Reversing file content is done by the tac command, not tee.

BUse the output of one command as arguments to another.

Using output of one command as arguments to another is the function of xargs, not tee.

CAdd line numbers to the output of a command.

Adding line numbers to output is done with nl or cat -n, not tee.

DPipe the output of one command into the input of another.

Piping output from one command into the input of another is performed by the shell pipe operator '|', not tee.

ESend a command's output to stdout and a to file at the same time.Correct

The tee command is named after a T-shaped pipe fitting because it splits output in two directions at once. It reads from standard input and writes the data to both standard output and to one or more files simultaneously, allowing a pipeline to continue while also capturing output to a file.

Concept tested: Linux tee command stdout and file redirection

Source: https://www.gnu.org/software/coreutils/manual/html_node/tee-invocation.html

Topics

#tee command#stdout#I/O redirection

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice