Answers for "bash check if dir is empty"

C++
0

bash test empty directory

#!/bin/bash

DIR="/empty_dir"

# look for empty dir 
if [ "$(ls -A $DIR)" ]; then
     echo "Take action $DIR is not Empty"
else
    echo "$DIR is Empty"
fi
Posted by: Guest on May-30-2021

Browse Popular Code Answers by Language