LFCS · 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 is used to display all shell variables, environment variables, and shell functions within the current shell session.
Question
Options
- Aenv
- Bset
- Cenv -a
- Decho $ENV
How the community answered
(14 responses)- B93% (13)
- D7% (1)
Why each option
The `set` command in Bash is used to display all shell variables, environment variables, and shell functions within the current shell session.
The `env` command primarily displays or sets environment variables, not all shell variables or functions.
The `set` command without any options outputs all shell variables, including local variables, environment variables, and shell functions, providing a comprehensive list of what's defined in the current shell session.
The `env -a` option is not a standard or valid option for the `env` command to list all variables and functions; `env` focuses on environment variables.
`echo $ENV` would only print the value of the `ENV` environment variable, which usually points to a script to be sourced, not a list of all variables and functions.
Concept tested: Bash variable and function listing
Source: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#index-set
Topics
Community Discussion
No community discussion yet for this question.