Linux Commands - unset (undefine a variable)

by
Jeremy Canfield |
Updated: August 13 2020
| Linux Commands articles
Lets say you've created a variable that contain a value, like this.
foo="bar"
When you echo $foo, bar is returned.
echo $foo
bar
The unset command will undefine the variable. In this example, the foo variable will no longer be defined.
unset foo
Now, when you attempt to echo $foo, nothing is returned, since foo has been unset.
echo $foo
Did you find this article helpful?
If so, consider buying me a coffee over at