LFCS Exam QuestionsBrowse all questions from this exam

LFCS Exam - Question 81


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

Show Answer
Correct Answer: D

In Bash, the correct syntax to set a variable named TEST with the content FOO is TEST="FOO". This command assigns the string FOO to the variable TEST. The other provided options either use incorrect syntax or do not achieve the intended result.

Discussion

2 comments
Sign in to comment
rona962Option: D
Apr 13, 2023

The command that sets the Bash variable named TEST with the content FOO is option D, TEST="FOO". Explanation: Option A, set TEST="FOO", sets the positional parameters of the current shell to TEST=FOO. It does not set the variable TEST. Option B, TEST = "FOO", attempts to run a command named TEST with two arguments, = and "FOO". It does not set the variable TEST. Option C, var TEST="FOO", is not valid Bash syntax for setting a variable. It is likely used in a different shell or programming language. Option D, TEST="FOO", sets the variable TEST to the string FOO. Therefore, to set the Bash variable named TEST with the content FOO, you should use the command TEST="FOO".

StribOption: D
Jun 17, 2023

D is correct