I'm creating some setup scripts that take me from a fresh installation to a
configured system.
One thing I need to be able to do is look for a section in a configuration
file, and if its there replace it with the contents of a separate file, and if
its not there to append the new settings to the file.
So for example I might want to insert the contents of a file mySettings.txt
into myProgram.conf, where mySettings.txt looks like:
mySetting = myValue
On the first run, it will append
# BEGIN mySettings
mySetting = myValue
# END mySettings
.. and on subsequent runs will replace the text between the BEGIN/END comments
with the text from my file.
I think something like sed should do what I want but I don't know it well
enough to tame it just yet. But maybe there are better tools anyway?
In my specific case I need to automatically insert some entries into the users
crontab:
crontab -l | <my insertion code here> | crontab -
Mark
--
Mark Rogers // More Solutions Ltd (Peterborough Office) // 0844 251 1450
Registered in England (0456 0902) 21 Drakes Mews, Milton Keynes, MK8 0ER
_______________________________________________
Peterboro mailing list
Peterboro@mailman.lug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/peterboro