[plug] Extreme text editing

Kimberly Shelt kim at linmagau.org
Tue Oct 7 22:32:37 WST 2003


On Tue, Oct 07, 2003 at 10:11:08PM +0800, Bernard Blackham wrote:
> 
> A crude way would be something like:
> 
> $ (head -10557151 bigfile ; echo 'new line here' ; tail +10557153 bigfile) > newbigfile
> $ mv newbigfile bigfile.
> 
> Though this requires creating a copy of the file which is possibly
> what took so long in the first place.
> 
> My solution #2, if the changes didn't involve changing the filesize
> (ie, no insertions), then you could write a small program (C, Perl,
> whatever bloats your float) to open it in rw mode, seek to the right
> offset (test by reading the data at the seek point), write the new
> bytes, and close... but it was probably safer with vi :) Though this
> method would be much faster.
> 
> Ideally, you'd use a hexediter to do it for you, if you could find a
> hex editor which didn't read the entire file on load.

Isn't sed supposed to shine in this department ?#
Line by line and all that ??



More information about the plug mailing list