nerdexam
Linux_Foundation

LFCS · Question #535

Which of the following bash options will prevent an administrator from overwriting a file with a ">"?

The correct answer is C. set -o noclobber. The set -o noclobber bash option prevents accidental overwriting of existing files when using redirection operators like >.

Submitted by fatima_kr· Apr 18, 2026Essential Commands

Question

Which of the following bash options will prevent an administrator from overwriting a file with a ">"?

Options

  • Aset -o safe
  • Bset -o noglob
  • Cset -o noclobber
  • Dset -o append
  • Eset -o nooverwrite

How the community answered

(18 responses)
  • B
    6% (1)
  • C
    89% (16)
  • D
    6% (1)

Why each option

The `set -o noclobber` bash option prevents accidental overwriting of existing files when using redirection operators like `>`.

Aset -o safe

`set -o safe` is not a standard bash option for preventing file overwrites; it is not recognized by the bash shell.

Bset -o noglob

`set -o noglob` disables pathname expansion (globbing), meaning characters like `*`, `?`, and `[]` are treated as literal characters, which is unrelated to preventing file overwrites.

Cset -o noclobberCorrect

The `noclobber` option specifically prohibits the redirection operators `>` and `>&` from overwriting an existing file. If an attempt is made to overwrite an existing file with `>`, the shell will report an error instead of destroying the file's contents, providing a safeguard against unintended data loss.

Dset -o append

`set -o append` is not a standard bash option; `>>` is the operator for appending, and `noclobber` would still apply if attempting to create a new file with `>>` that already exists (though it primarily targets `>`).

Eset -o nooverwrite

`set -o nooverwrite` is not a standard bash option for preventing file overwrites; no such option exists in bash.

Concept tested: Bash shell `noclobber` option

Source: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#The-Set-Builtin

Topics

#bash options#redirection#noclobber#shell configuration

Community Discussion

No community discussion yet for this question.

Full LFCS Practice