Bash – How to write a shell-script that will email me a file if the file is not empty

bashemailshell

I'm looking for a script I can run to check if a text file is empty, if it is then do nothing but if it has something in it, I want it to send me an email with the text file as the message. No idea how to do it.

Best Solution

[ -s "$f" ] && mail me@example.com -s "$f contents" < $f

Nice and compact :)