builtin

Bash unset — remove a variable

Removes named variables; -v explicitly selects variables. Readonly variables cannot be unset. Functions and array details are outside this entry.

Formal Syntax & Structure

bash syntaxbash
unset [-v] name ...

Parameters & Attributes

NameTypeDescription
namestringVariable name.

Return Value

exit status

Zero on success, nonzero for an error.

Working Example

Example Snippetbash
unset labelprintf 'unset=[%s]\n' "$label"label=printf 'empty=[%s]\n' "$label"
Bash Reference