From: "Michael D. Schleif" <mds(_at_)helices(_dot_)org>
Date: Thu, 26 Jun 2003 20:52:30 -0500
To: procmail(_at_)lists(_dot_)rwth-aachen(_dot_)de
Subject: Re: Adding dashes to phone number in subject
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Also sprach G.M. Wayne (Thu 26 Jun 02003 at 06:04:12PM -0700):
I receive email notification of voicemail messages, including the Caller ID
<snip />
SO... What is my problem? Well, I would like to add dashes in the phone
number in the subject field to make it more readable, and I cannot figure
out how to do it with either Procmail or formail or sed.
<snip />
Does this brute force help?
echo 1234567890 | sed 's!\(...\)\(...\)!\1-\2-!'
- --
Best Regards,
mds
Brute Force?? This is elegant compared to what I finally came up with! Thank
you very much - it works perfect!
Here is what I finally came up with last night, after stumbling across the
use of 'dd' in a procmail FAQ:
NEWSUB1= Just the phone number, with no spaces, dashes or alpha characters
NEWSUB2=`echo ${NEWSUB1} | dd bs=1 count=3`
NEWSUB3=`echo ${NEWSUB1} |sed -e 's/'${NEWSUB2}'//g'`
NEWSUB4=`echo ${NEWSUB3} | dd bs=1 count=3`
NEWSUB5=`echo ${NEWSUB3} |sed -e 's/'${NEWSUB4}'//g'`
NEWSUB=${NEWSUB2}-${NEWSUB4}-${NEWSUB5}
It works, but not near as nicely as your one liner! (I nearly twisted my
arm, patting myself on the back when I came up with this, now I am humbled
by your solution!)
Now I will have to break it down, to see exactly WHY it works (I'm a sed
newbie).
Thanks again!
Griffin
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail