Skip to content

Instantly share code, notes, and snippets.

@roeyk
Created March 18, 2014 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roeyk/9612682 to your computer and use it in GitHub Desktop.
Save roeyk/9612682 to your computer and use it in GitHub Desktop.
#!/usr/bin/bash
shopt -s dotglob nullglob
# returns true if empty, false otherwise
is_empty_dir() {
set - "echo $1/*"
test -z "$1"
}
#if [ "$is_empty_dir(/media/btrfs)" ]; then
if [ "$is_empty_dir(/home/roey/emptydir/)" ]; then
echo "/media/btrfs is empty!"
exit 1
else
echo "/media/btrfs is NOT empty!"
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment