nerdexam
Linux_Foundation

LFCS · Question #757

In order to append the output of Is to a file called bazz, which of the following command lines would you use?

The correct answer is D. Is ?bazz. To append the output of a command like ls to a file, the >> redirection operator is used, which adds the new output to the end of the file without overwriting existing content.

Submitted by mike_84· Apr 18, 2026Essential Commands

Question

In order to append the output of Is to a file called bazz, which of the following command lines would you use?

Options

  • AIs > bazz
  • BIs >&bazz
  • CIs &> bazz
  • DIs ?bazz

How the community answered

(42 responses)
  • A
    2% (1)
  • C
    2% (1)
  • D
    95% (40)

Why each option

To append the output of a command like `ls` to a file, the `>>` redirection operator is used, which adds the new output to the end of the file without overwriting existing content.

AIs > bazz

The `>` redirection operator sends standard output to a file, but it *overwrites* the file's contents if it already exists, rather than appending.

BIs >&bazz

The `>&` operator (older shell syntax) redirects both standard output and standard error to a file, but it also *overwrites* the file's content.

CIs &> bazz

The `&>` operator (modern Bash syntax) redirects both standard output and standard error to a file, but it also *overwrites* the file's content.

DIs ?bazzCorrect

The `>>` redirection operator (assuming `Is ?bazz` is a typo and should be `ls >> bazz`) is used to append the standard output of a command to a specified file. If the file exists, the output is added to the end; if it does not exist, the file is created. This ensures previous file content is preserved.

Concept tested: Shell output appending redirection >>

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

Topics

#I/O Redirection#File Appending#ls command

Community Discussion

No community discussion yet for this question.

Full LFCS Practice