Delete a variable in Bash

Example

To delete the variable MYVAR, execute

unset MYVAR

Demonstration

Create the variable MYVAR

MYVAR=heihei.ru

Make sure it is printed to the terminal with echo. Don't forget to add $

echo $MYVAR

heihei.ru

Remove the value from the variable with unset and check the result.

unset MYVAR
echo $MYVAR

The result should be an empty string.

Where I used this

For example, to create a unique UID for a network interface.

Article author: Andrei Olegovich