Unix Shell – Check If Directory Is Empty
| Posted by watashii | Filed under Programming, UnixHere is a simple unix shell command to check if a directory, $dir, is empty.
export $dir=/tmp/myfiles/
if [ "$(ls -A $dir)" ];
then
echo "$dir NOT Empty";
else
echo "$dir IS Empty";
fi