bash - pipe command to mailx and do not send mail if no content -


i have system (rhel5) not support mailx's -e option (for not sending email if body empty). there 1 liner use simulate feature? eg first send, 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" sort of relative, since these technically one-liners 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 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -