nerdexam
CompTIA

LX0-104 · Question #243

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

The correct answer is C. set -o noclobber. This question identifies the bash option that prevents accidental file overwriting using output redirection.

Shells, Scripting and Data Management

Question

Which of the following bash option 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

(49 responses)
  • B
    2% (1)
  • C
    94% (46)
  • E
    4% (2)

Why each option

This question identifies the bash option that prevents accidental file overwriting using output redirection.

Aset -o safe

set -o safe is not a standard bash option for preventing file overwrites.

Bset -o noglob

set -o noglob prevents pathname expansion (globbing), meaning characters like *, ?, and [] are treated as literal characters, not for file matching.

Cset -o noclobberCorrect

The set -o noclobber (or set -C) bash option prevents the shell from overwriting an existing file using output redirection operators like > or >&. If a file already exists, the redirection attempt will result in an error, protecting the file's contents.

Dset -o append

set -o append is not a standard bash option, though >> is the append redirection operator.

Eset -o nooverwrite

set -o nooverwrite is not a standard bash option for preventing file overwrites.

Concept tested: Bash shell options for file protection

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

Topics

#bash options#redirection#noclobber

Community Discussion

No community discussion yet for this question.

Full LX0-104 Practice