bash check if a folder is empty or not
To check if a folder is empty of not, you can use
1 2 3 4 5 6 |
if [ "$(ls -A /home/boby/1/ )" ] then echo "Files found" else echo 'No files found' fi |
If you want to reverse the checking, you can use !
1 2 3 4 5 6 |
if [ ! "$(ls -A /home/boby/1/ )" ] then echo "No files found" else echo 'Files found.' fi |
See bash