Skip to content

Welcome to Tech by Example

Menu
  • Home
  • Posts
  • System Design Questions
Menu

How to unset a variable in bash or terminal (Linux)

Posted on July 7, 2021July 7, 2021 by admin

unset command can be used to unset a variable in the terminal.

Let’s see an example

test=some_value
echo "Value before unset=$test"
unset test
echo "Value after unset=$test"

Output

Value before unset=some_value
Value after unset=

As you can see from the output above that the value of variable test becomes empty after unset command is run.

  • env
  • unset
  • ©2025 Welcome to Tech by Example | Design: Newspaperly WordPress Theme