I have this incomplete command:
find /var/www/vhosts/domain/folder/ -name '*.flv' -size +5000k && /bin/mail -s "The file is available!" "my@address.com" > /dev/null
I’m not able to insert a conditional, if the file is more than 5000k it must send mail, else no.
Thank you.
findalways returns an exit code of 0 except if there was something wrong. Therefore you have to use something else to generate an appropriate exit code (!=0) that can be used with&&. I would suggestgrep, e.g.:If grep detects a line containing the string
flvin the output offindit returns 0, otherwise 1. Themailcommand will only be executed on exit code 0 ofgrep.