Linux Foundation Certified System Administrator Exam: Command Line Output - LFCS Exam

What Output is Created by the Command Line "echo "foo bar" | tee bar | cat"?

Question

When given the following command line.

echo "foo bar" | tee bar | cat

Which of the following output is created?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

B

The command echo "foo bar" | tee bar | cat can be broken down into three parts, each separated by the pipe | character:

  1. echo "foo bar": This command simply prints the string "foo bar" to standard output.

  2. tee bar: This command takes the standard input it receives from the previous command (echo "foo bar") and writes it both to standard output (which will be piped to the next command) and to a file called "bar".

  3. cat: This command simply reads from its standard input (which is coming from the output of the previous command, tee bar) and writes it to standard output. Since there is no input coming after cat, it will simply wait for input from tee bar.

So the output of the command line will be "foo bar", which will be printed to standard output by cat. Therefore, the correct answer is B. "foo bar".