3
0
Note: the complementary question is here: How to separately sort lines within multiple “chunks” separated with headers?
So what I did find an answer to, is how to sort lines in a text files alphabetically. But, it is not exactly what I need to do. I have this file with profiles containing 15 different parameters that goes into an instrument at work and is read by the machine to have a list of profiles.
Sadly, the formatting of this file looks like this:
[ProfileB]
param1=z
param2=y
param3=x
[ProfileA]
param1=k
param2=l
param3=
And I want to sort the Profiles alphabetically, but I need them to stay grouped with their parameters. The above example should be sorted like this:
[ProfileA]
param1=k
param2=l
param3=
[ProfileB]
param1=z
param2=y
param3=x
I guess there is something to work either with the fixed number of lines (name+parameters) or with the character "[" as an identifier for the beginning of a group of lines.
But this is beyond my capacity in text manipulation. I have at my disposition either Sublime Text, R, or Linux command console.
Does the "instrument" require the profiles to be sorted? – glenn jackman – 2018-06-01T12:08:08.663
2I hope somebody can help you but in the meantime you should learn an interpreted language, not as heavy as C, and not as fiddly as bash. Something like ruby or python or perl. – barlop – 2018-06-01T14:08:34.773
@glennjackman No but if the file is not sorted, the profile are loaded in the same order as the one in the file. – Paul Giroud – 2018-06-04T08:51:34.403
1@barlop I do have basics in python and perl, and I am willing to use them (which is what I meant by access to the command console) – Paul Giroud – 2018-06-04T08:53:37.573