Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Editing files within a script

Status
Not open for further replies.

Antistatic

Technical User
Jan 4, 2001
36
0
0
CA
Hi All,
I've been trying to automate my reconfigurations and I'm having trouble editing a file on the fly. What I want to do is to replace a hostname and IP address in /etc/rc.config.d/netconf among other things but I can't seem to make SED do what I want.

I'm loading my system from an image tape so I do know what the old hostname and IP address is but that is a little TOO brute force. The image tape was made in single user mode so upon the software load these questions are asked and it slows down the loading process.

Any ideas????? >:):O>
 
Hi, just browsing thru to pick up some tips.

to change strings using sed, where you don't know the final half of the line, you could do as follows..

more /etc/rc.config.d/netconf | \
sed -e "s/HOSTNAME=[[:print:]]*/HOSTNAME=\"machine01\"/" \
-e "s/IP_ADDRESS\[0\]=[[:print:]]*/IP_ADDRESS[0]=12.345.67.89/"

(looks really ugly in this small box)

the key to this is the [[:print:]]*, which means any printable character (the * is 0 or more repeats).

probably too late to be useful, but anyway..
 
Thanks for the tip, its never too late, because here at the corporate training centre I'm constantly reloading and reconfiguring the networks and any thing that speeds up the process is a good thing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top