nerdexam
Linux_Foundation

LFCS · Question #726

Which of the following statements is correct regarding the command foo 1> bar?

The correct answer is B. The stdout from the command foo overwrites the file bar. The command foo 1> bar redirects the standard output of the foo command to the file bar, overwriting any existing content in bar.

Submitted by eva_at· Apr 18, 2026Essential Commands

Question

Which of the following statements is correct regarding the command foo 1> bar?

Options

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

How the community answered

(25 responses)
  • B
    92% (23)
  • C
    4% (1)
  • D
    4% (1)

Why each option

The command `foo 1> bar` redirects the standard output of the `foo` command to the file `bar`, overwriting any existing content in `bar`.

AThe stdout from the command foo is appended to the file bar.

Appending standard output to a file is achieved using the `>>` operator (e.g., `foo 1>> bar`).

BThe stdout from the command foo overwrites the file bar.Correct

The `1>` operator explicitly redirects file descriptor 1 (standard output). A single `>` redirection operator overwrites the contents of the target file if it already exists, or creates the file if it doesn't.

CThe command foo receives its stdin from the file bar.

Receiving standard input from a file is done using the `<` operator (e.g., `foo < bar`).

DThe command foo receives its stdin from the stdout of the command bar.

Receiving standard input from the standard output of another command typically uses a pipe (`|`) (e.g., `bar | foo`).

EThe stderr from the command foo is saved to the file bar.

Redirecting standard error (file descriptor 2) to a file uses the `2>` operator (e.g., `foo 2> bar`).

Concept tested: Standard output redirection

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

Topics

#Shell redirection#Standard output#File redirection#Overwriting files

Community Discussion

No community discussion yet for this question.

Full LFCS Practice