Open System Services Shell and Utilities Reference Manual (G06.27+, H06.04+)
User Commands (t - u) unset(1)
NAME
unset - Removes environment variable or function definitions
SYNOPSIS
unset [-fv] name
FLAGS
-f The name argument refers to function names.
-v The name argument refers to an environment variable name.
DESCRIPTION
The values of the variables or functions given as the name argument are unassigned; that is, the
values and attributes of the names are erased. Read-only variables cannot be unset.
If the -f flag is set, the name given as the name argument refers to a function name.
If the -v flag is specified, the name given as the name parameter refers to a variable name, and the
shell unsets it and removes it from the environment.
If neither the -f nor -v flag is specified, name refers to a variable.
Unsetting ERRNO, LINENO, OPTARG, OPTIND, RANDOM, SECONDS, TMOUT, and _
removes their special meaning, even if they are subsequently assigned.
EXAMPLES
1. The following commands set, check, reset, and recheck the value of a variable x. After x
has been unset, the echo x command returns null, confirming that the value of x has been
unset.
x=100
echo $x
100
unset x
echo $x
NOTES
• Parameter assignment lists that precede the command remain in effect when the com-
mand completes.
• I/O redirections are processed after parameter assignments.
• Errors cause a script that contains the commands so marked to abort.
The unset command is a shell built-in command. It differs from the regular commands in that it
does not open a new shell process when it executes.
A general discussion of shell built-in commands and a list of the OSS shell built-in commands
are in the reference page for sh(1).
RELATED INFORMATION
Commands: set(1), sh(1).
527188-004 Hewlett-Packard Company 9−37