nerdexam
LPI

102-500 · Question #88

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

The correct answer is D. set. set (D) lists all shell variables, environment variables, and functions defined in the current Bash session - making it the most comprehensive command for inspecting the shell's full state. Why the distractors are wrong: A. env - shows only exported environment variables, not…

Shells and Shell Scripting

Question

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

Options

  • Aenv
  • Bexport
  • Cenv -a
  • Dset
  • Eecho $ENV

How the community answered

(27 responses)
  • A
    4% (1)
  • B
    11% (3)
  • C
    7% (2)
  • D
    74% (20)
  • E
    4% (1)

Explanation

set (D) lists all shell variables, environment variables, and functions defined in the current Bash session - making it the most comprehensive command for inspecting the shell's full state.

Why the distractors are wrong:

  • A. env - shows only exported environment variables, not shell-local variables or functions.
  • B. export - with no arguments, lists only exported variables (similar to env), not functions or unexported locals.
  • C. env -a - not a standard flag; -a is not widely supported and even where it exists, env still only covers environment variables.
  • E. echo $ENV - prints the path to a startup file (if set), not a list of variables or functions.

Memory tip: Think of set as "see everything" - it's the broadest of the bunch. If you need just exported variables, use env or export; if you need everything (locals + globals + functions), use set.

Topics

#bash built-ins#shell variables#functions#environment

Community Discussion

No community discussion yet for this question.

Full 102-500 Practice