Back to the command reference

unset

ShellFundamentals In simulator In real Linux

Remove a variable

Name: unset

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

unset is a shell builtin that removes variables (or functions with -f). The variable then no longer exists, which differs from setting it to an empty string; ${var:-default} and [ -v var ] can tell the difference.

Syntax

unset NAME...

Common options

-vRemove variables (the default)
-fRemove a function

Examples

  • $ export TEMP=1 && unset TEMP

    Set a variable, then remove it

    Explain

Related