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

Which of the following commands lists all defined variables and functions within Bash?
A .  env
B .  set
C .  env -a
D .  echo $ENV

Answer: B

Subscribe
Notify of
guest
4 Comments
Inline Feedbacks
View all comments
smac
smac
3 years ago

B
you can set functions with set. you can also unset them with:
unset -f (function_name)

Hugh
Hugh
3 years ago

I mean it’s B, not A.

Hugh
Hugh
3 years ago

It’s A.
env does not list functions

Refer to the link below.
https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html

“If no options or arguments are supplied, set displays the names and values of all shell variables and functions”

metal
metal
4 years ago

Answer should be A, env command used to view environment variables for the current shell. set command is used to define and determine the values of the system environment.