[NTLUG:Discuss] In-place file editor

David Stanaway david at stanaway.net
Sun Sep 24 15:19:55 CDT 2006


You need the -i switch for sed.


eg:

sed i -e s/10.12.14.16/2.3.4.5/g fixfile




Leroy Tennison wrote:
> Looking for a scriptable (non-interactive) program which will modify a 
> text file without deleting the original and replacing it with a new 
> one.  The reason is that the file has permissions associated with it 
> that I don't want to destroy and recreate.  I thought that sed's 'w' 
> command would do it:
> 
> s/10.12.14.16/2.3.4.5/wfixfile fixfile
> 
> but it truncates 'fixfile'.  Problem is that I'm wanting to modify the 
> data (change 10.12.14.16 to 2.3.4.5 in the example) in 'fixfile'.  If 
> I'm just doing it wrong then please post the way to do it.  If sed isn't 
> the program I need then is there one available?
> 
> Thanks for the input.
> 
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
> 





More information about the Discuss mailing list