nerdexam
CompTIA

LX0-104 · Question #91

Which of the following commands lists all defined variables and functions within Bash?

The correct answer is B. set. The set command in Bash, when invoked without arguments, displays all shell variables, environment variables, and shell functions. This provides a comprehensive overview of the current shell's state.

Shells, Scripting and Data Management

Question

Which of the following commands lists all defined variables and functions within Bash?

Options

  • Aenv
  • Bset
  • Cenv -a
  • Decho $ENV

How the community answered

(21 responses)
  • B
    95% (20)
  • D
    5% (1)

Why each option

The `set` command in Bash, when invoked without arguments, displays all shell variables, environment variables, and shell functions. This provides a comprehensive overview of the current shell's state.

Aenv

The `env` command primarily lists environment variables, not all shell variables or shell functions.

BsetCorrect

The `set` command without any options lists all shell variables, including environment variables, and all defined shell functions for the current Bash session. This makes it the most comprehensive command for inspecting the entire state of the shell regarding variables and functions.

Cenv -a

`env -a` is not a standard or valid option for the `env` command; `env` only lists environment variables.

Decho $ENV

`echo $ENV` would print the value of the `ENV` variable if it is set, which typically points to a shell initialization file, not a list of all variables and functions.

Concept tested: Bash shell - variable and function listing

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

Topics

#Bash variables#Bash functions#set command

Community Discussion

No community discussion yet for this question.

Full LX0-104 Practice