Stripping extra stuff from text

@lbutlr kremels at
Wed Apr 29 18:30:39 CEST 2015

I have the following which generates a 140 character blog for sending me an SMS alert:

MSGTEXT=`/usr/local/bin/formail -I ""`
SMSTEXT=`echo $MSGTEXT | lynx --dump --dont_wrap_pre -stdin | tr '\n' ' ' | /usr/bin/cut -c1-140`

      | (formail -brt -I"Subject: ${CLEANFROM}" \
        -I"To: ${MOBILE}" \
        -I"From: lbuter at"; \
        echo $SMSTEXT) | $SENDMAIL -t

This works fine, but I end up with text like:

SMS:    This is the body of the email. It should be more than 140 characters to    = test if the cut pipe is working and if this message will be 

As you can see, I have leading spaces, and an extraneous =, but if I remove lynx from the chain, I will get HTML crap in the message on those messages.

Is there a simple way to remove any extra space AND encoding cruft, or do I just need to stack up some tr or sed pipes? 

"Why, you stuck-up, half-witted, scruffy-looking... NERFHERDER!"
"Who's Scruffy looking?"

More information about the procmail mailing list