[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Replace line in file based on pattern



On 1/2/22 6:40 PM, Greg Wooledge wrote:
On Sun, Jan 02, 2022 at 06:20:15PM -0500, The Wanderer wrote:

Of course, given the ORIGINAL question, the best tool is neither of these.
It's something like ansible or puppet.  Or if you insist on jury-rigging
crap together with stone knives and bearskins, ssh and patch.


Regarding "patch", let's consider a "stock" config file from a fresh install (call it NEW), and an existing config which is tweaked for my purposes (call it OLD). Assume I want the stock config altered to conform to my existing/working installation.

To make patch work, I need a diff file, which I get from diffing OLD and NEW. From there, I use patch and the diff to bring NEW to conform to OLD, more or less.

Once I've gone through this whole evolution, how is this process different from simply copying OLD over the top of NEW? Bear in mind that we aren't working with C files here, but config files, where changes are minimal and possibly confined to a small area.

I'm not being sarcastic or argumentative. I'm genuinely trying to understand how patch would be a real/superior solution.

Paul


Reply to: