Answers for "is directory empty linux"

1

sh check if directory is empty

#!/bin/bash
DIR="/tmp"

if [ "$(ls -A $DIR)" ]; then
     echo "Wow, $DIR is not Empty"
else
    echo "$DIR is Empty"
fi
Posted by: Guest on June-25-2021
0

how to find empty directories in linux

find . -type d -empty # use this to find the empty files

find . -type d -empty -delete #use this to delete all empty dirctories
Posted by: Guest on June-17-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language