2
This question is complementary to this one: Sort packs of lines alphabetically. After answering there, it turned out I had totally misunderstood the question and solved another problem. Not wanting my solution to be forgotten, I'm posting the problem here (and my solution below).
Consider a text like:
[ProfileB]
param3=z
param2=y
param1=x
[ProfileA]
param1=k
param3=l
param2=
I need to sort parameters within every [Profile*]
block separately. The above example should be sorted to this:
[ProfileB]
param1=x
param2=y
param3=z
[ProfileA]
param1=k
param2=
param3=l
How can I do it with standard Unix/Linux tools?