All kudos to Rob Harley for his awesome answer. The trick was a) using
the [^] negation symbol: ^ in brackets means not but everywhere else
means beginning of a line and b) realizing that non-indent spaces are by
definition not preceded by a space.
You, sir, are a sed stud. Thanks.
Of course, he gets even more points for showing that 'lynx -justify=0'
does what I want (even though the lynx man page doesn't show -justify
taking an argument).
So, Rob got me from this:
| lynx -dump -force_html -stdin \
| sed -e 's/^\ \ \ \ \ /bigindent/' \
| sed -e 's/\ \+/\ /g' \
| sed -e 's/^\ /\ \ \ /g' \
| sed -e 's/^bigindent/\ \ \ \ \ /' \
| mutt $MAILLIST -s "${SUBJ_}"
To this:
| lynx -dump -force_html -stdin \
| sed -e 's/\([^ ]\) \+/\1 /g'
| mutt $MAILLIST -s "${SUBJ_}"
To this:
| lynx -dump -force_html -stdin -justify=0 \
| mutt $MAILLIST -s "${SUBJ_}"
Thanks man.
- dan
--
Dan Kohn <mailto:dan(_at_)dankohn(_dot_)com>
<http://www.dankohn.com/> <tel:+1-650-327-2600>
-----Original Message-----
From: Robert Harley [mailto:harley(_at_)argote(_dot_)ch]
Sent: Monday, June 24, 2002 02:21
To: fork(_at_)xent(_dot_)com
Cc: Dan Kohn
Subject: Re: Any sed/regex gurus around?
If I understand correctly, you should be able to just replace multiple
spaces, that follow a non-space, by a single space, like so:
sed -e 's/\([^ ]\) \+/\1 /g'
Hope this helps,
Rob.
.-.
.-.
/ \ .-. .-. /
\
/ \ / \ .-. _ .-. / \ /
\
/ \ / \ / \ / \ / \ / \ /
\
/ \ / \ / `-' `-' \ / \ /
\
\ / `-' `-' \ /
`-' `-'
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail