Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
bash: change 1 property in a properties file [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
kristoczaj
Apprentice
Apprentice


Joined: 18 Apr 2004
Posts: 201
Location: Poland

PostPosted: Sat Oct 14, 2006 8:34 pm    Post subject: bash: change 1 property in a properties file [solved] Reply with quote

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
View user's profile Send private message
Maedhros
Bodhisattva
Bodhisattva


Joined: 14 Apr 2004
Posts: 5511
Location: Durham, UK

PostPosted: Sat Oct 14, 2006 8:58 pm    Post subject: Reply with quote

Will sed work?
Code:
sed -i -e "/DccIP=/s/=.*/=$MYIP/" file.txt

_________________
No-one's more important than the earthworm.
Back to top
View user's profile Send private message
kristoczaj
Apprentice
Apprentice


Joined: 18 Apr 2004
Posts: 201
Location: Poland

PostPosted: Sat Oct 14, 2006 9:59 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum