Удалить переменную в Bash

Contents
Пример
Демонстрация
Применение
Related Articles

Пример

To удалить переменную MYVAR execute

unset MYVAR

Демонстрация

Создайте переменную MYVAR

MYVAR=heihei.ru

Убедитесь, что она выводится в терминал с помощью echo. Не забудьте поставить $

echo $MYVAR

heihei.ru

Удалите значение из переменной с помощью unset и проверьте результат.

unset MYVAR
echo $MYVAR

Должна быть пустая строка.

Где я это применял

Например, для создания уникального UID для сетевого интерфейса.

Article author: Andrei Olegovich

Related articles
Bash
Bash Scripting
-eq -gt …: Операторы сравнения
if else: Условные операторы
Цикл while
date: Дата
Переход на новую строку
Арифметические операции
Передать файл или пароль по SFTP в Bash скрипте
Errors Bash
Banner image

Search this site

Subscribe to Telegram channel @aofeed to follow new articles and updates to old ones

Go to channel

@aofeed

Ask a question in the Telegram group

@aofeedchat

Contacts and cooperation:
I recommend our hosting beget.ru
Write to info@urn.su, info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: