From 65a200232331dd0746a94d0807620b977715edb4 Mon Sep 17 00:00:00 2001 From: neingeist Date: Mon, 27 Feb 2023 21:27:03 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20dir-empty:=20Check=20if=20directori?= =?UTF-8?q?es=20are=20empty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dir-empty | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 dir-empty diff --git a/dir-empty b/dir-empty new file mode 100755 index 0000000..b57cf5b --- /dev/null +++ b/dir-empty @@ -0,0 +1,10 @@ +#!/bin/sh +# Check that all of the given directories are empty + +for d in "$@"; do + if [[ -n "$(ls -1 "$d")" ]]; then + exit 1 + fi +done + +exit 0