nerdexam
Linux_Foundation

LFCS · Question #863

When given the following command line. echo "foo bar" | tee bar | cat Which of the following output is created?

The correct answer is B. foo bar. The echo command outputs "foo bar", which tee writes to a file named bar and also passes to cat, resulting in "foo bar" being printed to standard output.

Submitted by suresh_in· Apr 18, 2026Essential Commands

Question

When given the following command line. echo "foo bar" | tee bar | cat Which of the following output is created?

Options

  • Acat
  • Bfoo bar
  • Ctee bar
  • Dbar
  • Efoo

How the community answered

(26 responses)
  • B
    88% (23)
  • C
    4% (1)
  • D
    8% (2)

Why each option

The `echo` command outputs "foo bar", which `tee` writes to a file named `bar` and also passes to `cat`, resulting in "foo bar" being printed to standard output.

Acat

`cat` is the command itself, and it will output its input, not its own name.

Bfoo barCorrect

The `echo "foo bar"` command sends the string "foo bar" to its standard output. This output is then piped to `tee bar`, which simultaneously writes "foo bar" to a file named `bar` and forwards the same string "foo bar" to its standard output. Finally, `cat` receives "foo bar" as its standard input and prints it to the console.

Ctee bar

`tee bar` is a command and arguments; the output of the pipeline is the data processed by the commands, not the command names.

Dbar

`bar` is the name of the file created by `tee`, not the data being passed through the pipeline to standard output.

Efoo

`foo` is only part of the string; the entire string "foo bar" is processed and output.

Concept tested: Command piping and `tee` utility

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

Topics

#Pipes#Standard I/O#tee command#Shell commands

Community Discussion

No community discussion yet for this question.

Full LFCS Practice