Post

check if a variable is empty

1
2
3
4
5
6
7
8
#!/bin/bash
echo -e "Enter favorite banana"
read -r BANANA

if [[ -z "$BANANA" ]]; then
  echo "No banana entered. Exiting."
  exit 1
fi
This post is licensed under CC BY 4.0 by the author.