LDP/LDP/guide/docbook/abs-guide/unset.sh

18 lines
491 B
Bash
Raw Normal View History

2001-07-10 14:25:50 +00:00
#!/bin/bash
2001-09-04 13:27:31 +00:00
# unset.sh: Unsetting a variable.
2001-07-10 14:25:50 +00:00
2009-09-29 15:08:03 +00:00
variable=hello # Initialized.
2001-07-10 14:25:50 +00:00
echo "variable = $variable"
2009-09-29 15:08:03 +00:00
unset variable # Unset.
# In this particular context,
#+ same effect as: variable=
echo "(unset) variable = $variable" # $variable is null.
2001-07-10 14:25:50 +00:00
2009-09-29 15:08:03 +00:00
if [ -z "$variable" ] # Try a string-length test.
2006-10-11 16:39:10 +00:00
then
echo "\$variable has zero length."
fi
2001-07-10 14:25:50 +00:00
exit 0