From 8d51bda0cc16facc668f02862f32f1cb8ac5d595 Mon Sep 17 00:00:00 2001 From: neingeist Date: Sun, 15 Nov 2015 18:36:49 +0100 Subject: [PATCH] Initial git commit --- check_dir_empty | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 check_dir_empty diff --git a/check_dir_empty b/check_dir_empty new file mode 100755 index 0000000..6113b2a --- /dev/null +++ b/check_dir_empty @@ -0,0 +1,18 @@ +#!/bin/sh + +dir=$1 + +if [ "$dir" = "" ]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +count=`find "$dir" -mindepth 1 -maxdepth 1 | wc -l` + +if [ "$count" = "0" ]; then + echo "OK: '$dir' is empty." + exit 0 +else + echo "WARNING: '$dir' is NOT empty ($count entries)." + exit 1 +fi