[NTLUG:Discuss] In-place file editor
Chris Cox
cjcox at acm.org
Sun Sep 24 15:36:57 CDT 2006
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
perl -pi -e 's/10\.12\.14\.16/2\.3\.4\.5/' fixfile
If it's to be globally, add g after last slash.
Need to escape the periods.. even in sed they
mean any character.
>
> 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