[[ $( find /folder/with/files -type f | wc -l ) -lt 3 ]] && mail -t [email protected] -s Problem <<< "Less than three files."
Find and wc -l return the count of files and then [[ evaluates if the count is lees than three. If this evaluates to true and returns zero exit status, next command after && is executed.
If the mail environment is set up correctly, mail with given subject and message will be sent.
1
solved Bash script to email when wc -l count is below 3