Re: Script to edit a file



Pascal Bourguignon wrote:
Benjamin <benjamin.dizenhouse@xxxxxxxxx> writes:

I'm new to unix and need some help creating a script to edit a file.

Lets assume the file's location is /opt/server_config
I need to edit the line in this file "hostname=<<followed by the
hostname>>" to become "hostname="

Is this possible via a script?
Thanks for any and all help!

Yes.


I would advise you to learn emacs which is a powerful and fully
scriptable editor.


Otherwise, for a lot of simple edits, you can use sed, (Stream EDitor).
For example:

For operating on a file in place, better to use ed than sed (thus the names, EDitor vs Stream EDitor).
.



Relevant Pages

  • Re: Trailing blanks in batch file
    ... Same applies to parentheses and quotes, ... problem as there *being* a trailing space whose presence creates a problem. ... If someone exclusively used an editor that displayed blanks as grey dots, ... can never be sure that one's script will never be edited by someone else ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: Writing and debugging VBS
    ... rem that out temporarily then re-run your script and see what ... > Editor in Excel or Word, in the hope that the editor would step through ... > screen changed for a few seconds, before reverting to the design mode. ... > (in a similar way to the VBA editor) to step through my VBS code? ...
    (microsoft.public.scripting.vbscript)
  • Re: Text Editor - Which to hack?
    ... I tried to script Emacs and man: ... then say you want an editor scriptable in something else than emacs lisp. ...
    (comp.programming.threads)
  • Re: Cannot Set Word As HTML Editor For IE6??
    ... that the path you gave it is correct for your installation? ... Alan Edwards, MS MVP W95/98 Systems ... >option for my HTML editor. ... >way it was before I ran the script. ...
    (microsoft.public.windows.inetexplorer.ie6.setup)
  • Re: JScript syntax higlihting in VIntDev
    ... :: JScript files and highlighted the syntax. ... select the HTML Editor and set the editor to come up in Source View. ... Document to link script ... : function doThis() { ...
    (microsoft.public.scripting.jscript)