nerdexam
Linux_Foundation

LFCS · Question #787

In the command foo < bar | foobar, which of the following statements is correct?

The correct answer is D. The command foobar receives its stdin from the stdout of foo. In the command foo < bar | foobar, the foo command reads its input from the file bar, and its standard output is then redirected as the standard input for the foobar command.

Submitted by brentm· Apr 18, 2026Essential Commands

Question

In the command foo < bar | foobar, which of the following statements is correct?

Options

  • AThe stdout from the command foobar is saved to the file foo.
  • BThe stdout from the command foo is saved to the file foobar.
  • CThe command foobar receives its stdin from the stderr of foo.
  • DThe command foobar receives its stdin from the stdout of foo.
  • EThe command bar receives its stdin from the contents of the file foobar.

How the community answered

(69 responses)
  • B
    3% (2)
  • C
    1% (1)
  • D
    94% (65)
  • E
    1% (1)

Why each option

In the command `foo < bar | foobar`, the `foo` command reads its input from the file `bar`, and its standard output is then redirected as the standard input for the `foobar` command.

AThe stdout from the command foobar is saved to the file foo.

The output of `foobar` is not saved to `foo`; `foobar` receives input from `foo` via the pipe.

BThe stdout from the command foo is saved to the file foobar.

The stdout of `foo` is piped to `foobar` as stdin, not saved to a file named `foobar`.

CThe command foobar receives its stdin from the stderr of foo.

The pipe (`|`) primarily redirects standard output to standard input, not standard error (stderr).

DThe command foobar receives its stdin from the stdout of foo.Correct

The pipe symbol (`|`) redirects the standard output (stdout) of the command `foo` to become the standard input (stdin) of the `foobar` command.

EThe command bar receives its stdin from the contents of the file foobar.

The command `bar` is actually a file whose content is provided as standard input to the `foo` command, not a command receiving input from `foobar`.

Concept tested: Linux shell I/O redirection and pipes

Source: https://man7.org/linux/man-pages/man1/bash.1.html

Topics

#Shell redirection#Pipes#Standard I/O#Command line basics

Community Discussion

No community discussion yet for this question.

Full LFCS Practice