nerdexam
Linux_Foundation

LFCS · Question #858

Which of the following command sets the Bash variable named TEST with the content FOO?

The correct answer is D. TEST="FOO". In Bash, variable assignment follows a specific syntax where the variable name is immediately followed by an equals sign and then the value, without any spaces.

Submitted by viktor_hu· Apr 18, 2026Essential Commands

Question

Which of the following command sets the Bash variable named TEST with the content FOO?

Options

  • Aset TEST="FOO"
  • BTEST = "FOO"
  • Cvar TEST="FOO"
  • DTEST="FOO"

How the community answered

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

Why each option

In Bash, variable assignment follows a specific syntax where the variable name is immediately followed by an equals sign and then the value, without any spaces.

Aset TEST="FOO"

The `set` command is primarily used for manipulating shell options or positional parameters, not for direct variable assignment in this format.

BTEST = "FOO"

Including spaces around the equals sign (`=`) in Bash variable assignments causes the shell to interpret the variable name as a command and the equals sign as an argument, resulting in a syntax error.

Cvar TEST="FOO"

`var` is not a keyword used for variable declaration or assignment in Bash; variables are implicitly created upon their first assignment.

DTEST="FOO"Correct

In Bash, the correct and standard syntax for assigning a value to a variable is `VARIABLE_NAME="VALUE"`, where there are no spaces immediately surrounding the equals sign, making `TEST="FOO"` the correct command.

Concept tested: Bash variable assignment syntax

Source: https://www.gnu.org/software/bash/manual/bash.html#Shell-Variables

Topics

#Bash variables#Variable assignment#Shell scripting basics#Command line

Community Discussion

No community discussion yet for this question.

Full LFCS Practice