unset - Unset values of variables and functions

Synopsis

unset [ -fv ] [ name ... ]

Description

You can use unset to unset each variable or function specified by name. If no option is specified, name refers to a variable. Variables with the read-only attribute cannot be unset.

Options

-f
name refers to a function.
-v
name refers to a variable.

Operands

Each name is a variable or function.

Exit status

  • 0 when successful.
  • >0 when at least one name could not be found. The value is the number of names that are not found.

Examples

  1. Unset the variable alpha: unset alpha
  2. Unset the function foo: unset -f foo