This is a small portion of a larger script, but it doesn't show the right result. I want it to check for a folder, if that folder exists then check for number of files in it. If empty then exit (continue with larger script). Or maybe it should be a large function? The script:
#!/bin/bash
BU_DIR=~/Backups
function Func_CountFiles() {
FILES=$(find ${BU_DIR} -type f | wc -l )
# echo $BU_FILES
}
### Get files from Backupfolder
#
if [ ! -d "${BU_DIR}" ]; then
BU_Status="Directory, ($BU_DIR), not found!"
else
Files=$(Func_CountFiles)
if [ $Files -le "0" ]; then
FU_Status="Current dir, ($BU_DIR), is empty."
else
# Files=$(Func_CountFiles)
BU_Status="Current dir, ($BU_DIR), contains $Files."
fi
fi
exit 0