Created
March 18, 2014 02:49
-
-
Save roeyk/9612682 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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