I have a system (rhel5) that does not support mailx
's -E
option (for not sending email if the body is empty). Is there a one liner that i could use to simulate this feature? eg the first would send, but the second wouldn't
echo 'hello there' | blah | mailx -s 'test email' me@you.com
echo '' | blah | mailx -s 'test email' me@you.com
Well. "one-liner" is sort of relative, since these are technically one-liners but they may not suit you:
stuff=$(echo 'hello there') ; [ -n "${stuff}" ] && echo ${stuff} | mailx -s 'test email' me@you.com
stuff=$(echo '') ; [ -n "${stuff}" ] && echo ${stuff} | mailx -s 'test email' me@you.com