1

I got a script running (as cronjob) that will list the files in a folder before doing a Rsync job and emailing me the list. How can I add a subject line.

find /path/to/folder/ -type f -size +1M -name "*.mov" -printf "%f\n" | ssmtp my_email@domain.com

I tried this with -s "Subject" but no luck. It only works if I put the subject in a text file and call this text file

find /path/to/folder/ -type f -size +1M -name "*.mov" -printf "%f\n" | my_email@domain.com < /path/to/file/subjectline.txt

But than it won't add the search results in the Message.

Any thoughts on what I am doing wrong,

Bas

3

Try this:

{
    echo To: my_email@domain.com
    echo From: from_email@example.com
    echo Subject: mov files greater than 1M
    echo
    find /path/to/folder/ -type f -size +1M -name "*.mov"
} | ssmtp my_email@domain.com

You don't need the printf on find.

  • Awesome that works really well. The only reason I had the -printf "%f\n" was to trim of the full path and just have the filenames. Thank you very much that was really helpful. – Bas Nov 20 '15 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.