Previously Mikael Djurfeldt wrote: > This seems to be a common thing to want to do, so I expect that a tool > for this already exists. Afaik no such tool exists, but it is quite easily done with sed and a little bit of sh: master=something.conf # Configuration file in which we want to insert data insert=/tmp/new # File with data we want to insert pkg=testpackage # Name of this package tmpfile=`tempfile` # Temporary file # Divider lines for our data start="#### start of #pkg section ####" end="#### start of #pkg section ####" # If the master configuration file exists copy the contents to our temporary # file but strip our previous data in there if [ -f $master ] ; then sed -e '/^$start/,/^$stop/d' $master > $tempfile fi # (Re)create the configuration file with our extra data cat $tempfile > $master echo $start >> $master cat $insert > $master echo $stop >> $master rm -f $tmpfile -- _________________________________________________________________ / Generally uninteresting signature - ignore at your convenience \ | wichert@liacs.nl http://www.liacs.nl/~wichert/ | | 1024D/2FA3BC2D 576E 100B 518D 2F16 36B0 2805 3CB8 9250 2FA3 BC2D |
Attachment:
pgpKvfS9vaf5h.pgp
Description: PGP signature