[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Program for quoting text like in email?



Thomas Anderson <andersonthomas@gmail.com> writes:

>> OK, so I guess it should be sed 's/^/> /'. 

>However I noticed another problem. When I quote a text that is already
>quoted, the result gets the "> " characters moved around. I would like
>to get ">> " or "> > " for text that is quoted twice. 

What do you mean by "moved around"? Can you post an example?

The sed script quoted above is very simple. It just puts "> " at the
start of each line and should not move anything around.

If you are piping the result to fmt(1), then I guess you'd see the
"moving around" you might be talking about. If this is the problem, you
may want to use par(1) instead (from the "par" package). par knows about
quoting and preserves it properly when reformatting. It's got quite a
few options, but I typically use it as "par 72q" - that uses 72 chars as
the max line width and handles quoting.

$ sed 's/^/> /' | par 72q

A slightly more complicated sed script to use not put an extra space
after the quote on already quoted text would be:

$ sed -e 's/^>/>>/' -e '/^\([^>]\|$\)/s/^/> /' | par 72q


Reply to: