Answers for "bash check directory empty"

C++
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

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

Code answers related to "bash check directory empty"

Browse Popular Code Answers by Language