Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


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

Re: edit a file in place



 On Wed, 2008-08-06 at 14:05 -0400, Matt Shields wrote: 
> On Wed, Aug 6, 2008 at 12:52 PM, Derek Martin <[hidden email]>wrote: 
> 
> > A coworker asked me if I could think of any Linux/Unix utility which 
> > would allow him to change one line of a file in place (i.e. without 
> > creating a temporary file a la sed and overwriting the old version a C 
> > program to do it -- you could, for example, mmap the file, move the block 
> > after the line to the right place (depending on whether the 
> > new line was longer or shorter), write the new line, and truncate the 
> > file if necessary.  This, of course, is way too much trouble to make 
> > it worthwhile. :) 
> > 
> > While personally I have no problem using temp files, I did wonder if 
> > there wasn't already something which could do this easily...  Anyone 
> > have any ideas? 
> > 
> Ed can do this.  For example I use this as part of my CentOS kickstart files 
> in the post section 
> 
> ed /etc/ssh/ssh_config <<EOF 
> %s/\#.*StrictHostKeyChecking ask/StrictHostKeyChecking no/ 
> w 
> EOF 


BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org