DIR=/u01/app/tomcat/apache-tomcat-9.0.43/work
if [ $(ls -A $DIR) ]
then
echo 'Folder is not empty'
else
echo 'Folder is empty'
fi
works fine and the output is
Folder is not empty.
however if I try it for /temp it fails. throwing error
DIR=/u01/app/tomcat/apache-tomcat-9.0.43/temp
if [ $(ls -A $DIR) ]
then
echo 'Folder is not empty'
else
echo 'Folder is empty'
fi
[: too many arguments Folder is empty
why is the /temp is not working.? The [: too many arguments Folder is empty error occurs only when the folder is not empty