On 3/26/06, Shane Stixrud shane@geeklords.org wrote:
Sed is a wonderful tool, but it is highly limited by the fact its user must take into account whole file(s) for each expression, this is further complicated when one must consider the file may change over time. The complexity and readability of regular expression tools is much higher than should be required to change OS/application variables.
Creating new files or appending to the end of existing files with "echo" only takes one so far. This also tends to have the cost of hurting readability as it is often the case you would prefer putting data somewhere else in the file (i.e. sed).
The nature of flat configuration files where each application has its own format is such where recovery and/or applying changes only if they have not been already applied is too complex and hurts readability far to much to be attempted in a simple shell script.
One tool I did not see you list is `patch`. A context diff can still work even when the file has changed significantly, and the format is extremely readable (just + or -.) Maintaining a collection of diffs is going to be significantly easier to manage than dealing with a large number of cp/mv/echo/sed commands in shell files. There are also a variety of tools made to deal with diffs and can show them in graphical, friendly ways.
There might be a good reason not to use diff/patch for doing what you want, but I think that it could save a few headaches.
n0dalus.