<<< Date Index >>>     <<< Thread Index >>>

Re: Changing Headers in the Compose screen



On Mon, Jan 19, 2004 at 07:43:09PM EST, Christoph Berg wrote:
> Re: David Yitzchak Cohen in <20040119194127.GW16674@xxxxxxx>

> > > > #!/bin/sh
> > > > file=$1
> > > > (
> > > >  echo "/From:/s/^.*\$/From: William O'Higgins 
> > > > <addy_I_want@xxxxxxxxxxx>/"
> > > >  echo "/Reply-To:/s/^.*\$/Reply-To: William O'Higgins 
> > > > <addy_I_want@xxxxxxxxxxx>/
> > > > wq"
> > > > ) | ed $file
> > > 
> > > Perl's -i switch is very handy for in-place editing.
> > 
> > Yeah, I know, but a lot of us treat it as a status symbol that we prefer
> > to automate an ed session :-)
> 
> You are welcome to use whatever tool you like :-)
> 
> Many people are usually annoyed that you can't do "filter < file > file"
> and have to use temp files; perl -i can be quite a relief. Using ed
> solves the same problem, but I wouldn't stick it with a MAX_INT-feet
> pole myself ;-)

LOL. . .

BTW - For a file less than 4096 bytes long, you can do this instead:
cat < file | filter | cat > file
as long as filter doesn't attempt to flush its output.  (The pipe buffers
hold all the intermediate data.)

For files of arbitrary length, you can replace the UNIX pipe buffer with
a small little program:
filter <file | read_everything_into_memory_and_spit_back_everything_on_eof >file

> > I mean, come on:
> > 
> > #!/usr/bin/perl -in
> 
> -pi (or -i -p), actually.

Yeah, my bad :-(

> > s/^From:.*\$/From: William O'Higgins <addy_I_want@xxxxxxxxxxx>/;
> > s/^Reply-To:.*\$/Reply-To: William O'Higgins <addy_I_want@xxxxxxxxxxx>/;
> > 
> > It just doesn't look nearly as cool as my pipeline to ed ;-P
> 
> You could have used a 'here' document ;)

When you use a here doc, you lose out on the need to escape all them
quotes.  Remember: the goal here is to have fun.

> Christoph [who only recently wrote his first sed script after years of
> perl groking]

I guess that explains why you wouldn't touch ed with a ULLONG_MAX-foot
pole ;-P

 - Dave

-- 
Uncle Cosmo, why do they call this a word processor?
It's simple, Skyler.  You've seen what food processors do to food, right?

Please visit this link:
http://rotter.net/israel

Attachment: pgpDDfUXghfKB.pgp
Description: PGP signature