From: Peter Seibel
Subject: Re: Overwriting or deleteing in text files
Date: 
Message-ID: <m34r5pf9jo.fsf@localhost.localdomain>
Anonymous Sender <·········@remailer.metacolo.com> writes:

> Newbie (self educating, at home,) I want to modify and remove and
> add text to html files My only previous (self taught) programming is
> with Autodesk Autolisp Using lispworks (free)
> 
> 
> (setq Current_File (open(car Target_File_List) :direction :io :if-exists
> :append ))
> 
> Reading from the file is OK and so is Writing (appending) to it but
> how do I overwrite or delete parts I could generate a complete new
> file, but this seems wasteful

And yet, there's no way around it, assuming you're on a
Unix/Windows-style filesystem. On such filesystems there's no way to
insert or delete bytes out of the middle of a file. You can seek to a
particular spot in the file and overwrite the bytes there. But that is
unlike to work for you unless the text you want to replace and the
text you want to replace it with are exactly the same length.

[1] Strictly speaking, you don't have to rewrite the *whole* file. If
the text you want to replace is at byte N, you could slurp up the rest
of the file, after byte N, into memory, truncate the file to N bytes,
and then write the replacement text, and whatever's left of the tail
of the file. But that's probably more trouble than it's worth.

-- 
Peter Seibel                                      ·····@javamonkey.com

  The intellectual level needed   for  system design is  in  general
  grossly  underestimated. I am  convinced  more than ever that this
  type of work is very difficult and that every effort to do it with
  other than the best people is doomed to either failure or moderate
  success at enormous expense. --Edsger Dijkstra