View previous topic :: View next topic |
Author |
Message |
kristoczaj Apprentice
Joined: 18 Apr 2004 Posts: 201 Location: Poland
|
Posted: Sat Oct 14, 2006 8:34 pm Post subject: bash: change 1 property in a properties file [solved] |
|
|
The file looks like this (actually it's a lot longer):
Code: |
[Look]
AlignUserboxIconsTop=false
ChatBgColor=#ffffff
ChatContents=
[Network]
AllowDCC=false
DccForwarding=false
DccIP=1.1.0.1
DccIpDetect=false
DefaultPort=8074
[Notify]
ConnError_Hints=false
ConnError_Sound=true
NewChat_Hints=false
|
I'm trying to write a bash script that would set the DccIP property in the Network section
What I want is:
DccIP=$MYIP
where MYIP is a variable that has been set.
Is there an easy way to do that?
Last edited by kristoczaj on Sat Oct 14, 2006 10:00 pm; edited 1 time in total |
|
Back to top |
|
|
Maedhros Bodhisattva
Joined: 14 Apr 2004 Posts: 5511 Location: Durham, UK
|
Posted: Sat Oct 14, 2006 8:58 pm Post subject: |
|
|
Will sed work?
Code: | sed -i -e "/DccIP=/s/=.*/=$MYIP/" file.txt |
_________________ No-one's more important than the earthworm. |
|
Back to top |
|
|
kristoczaj Apprentice
Joined: 18 Apr 2004 Posts: 201 Location: Poland
|
Posted: Sat Oct 14, 2006 9:59 pm Post subject: |
|
|
sed is great, thanks Maedhros.. I understand it doesn't check the section, and only looks for DccIP, but in this case that's good enough for me
Cheers |
|
Back to top |
|
|
|