Shell

unset

Unset shell variables or functions.

shellscriptbuiltin

Additional Notes

unset is a shell command used to unset shell variables or functions. It removes shell variables or functions from the environment, useful for cleanup in scripts.

Use unset VARNAME to remove a variable and unset -f FUNCNAME to remove a function. unset is specified by POSIX.

Syntax

unset [arguments]

Parameters

  • options: Flags that change how unset behaves.
  • arguments: Values consumed by the shell builtin or script command.
  • command: Command line to run, test, wrap, or control.

Common Options

  • --help: Show command help when supported.
  • --version: Show version information when supported.

Examples

unset --help
man unset

Practical Notes

Options can vary by distribution and package version. Use man unset, unset --help, or the package documentation for exact syntax.