Score:1

Sort two config files in the same order

br flag

I have two servers running the same set of internally developed apps. One is the "production" server, the other is the "dev/test" server. As time has gone on, the config files for the two have become more and "out of order". They mostly contain the same lines, but he values for each are different.

Here's an examples... Prod server

siteUID = server-prod
backend = prod
node = prod1
system.default.timezone = UTC

Dev Server

siteUID = server-dev
backend = dev
node = dev1
system.default.timezone = CST

So same variables, different values. As you get further down the files, the entries get more and more out of order. To be clear, the same entries are in each file (with different values), they are just in different order. Also, there are a few values on the prod server that simply don't exist on the Dev server.

I want to get these files (there's about 20 on each server, and some are several hundred lines long) sorted in the same order. Specifically, I want to make the values in config files on the Dev server match the same order as the Prod server.

Unfortunately I cannot simply sort them (say alphabetically) as these entries are often broken into specific sections (such as variables that are required by a specific release) that need to stay together.

Any idea on how I can force the Dev files to line up with the Prod files?

Ginnungagap avatar
gu flag
Write a script. Given the syntax, you'd grab the prod files, extract all keys in order, parse the other files as a dictionary and serialize them again based on the order of the pros ones. All in all, 20 lines of python (based on given examples).
br flag
That's certainly one option, and frankly what I suspected the answer would be. :( Sadly, my coding skills aren't up to the task so it would involve more research.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.