View Single Post

  #4 (permalink)  
Old 05-02-2005, 02:46 PM
monk's Avatar
monk monk is offline
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

Few days back i had read something as follows posted by vivek (old forum) which basically changes the values of the config file

Code:
CF="/etc/test.config" 
mod(){ 
NCF="$CF.$$" 
[ ! -f $CF ] && touch $CF || : 
V="$1" 
grep -v -E "^$V=" $CF > $NCF 
mv -f $NCF $CF 
eval echo "$V=\"'\${$V}'\"">> $CF 

} 

# test data
host='me.test.com' 
mod host 
mod ip
Save file and Execute

It will create /etc/test.config as follows
host='me.test.com'
ip=''

Again if you modify the script file with test data
host='YOU.test.com'

And script executed now output will be changed to as follows
host='YOU.test.com'
ip=''"

Try this one or may be we can play more with sed .... later ..
Reply With Quote