I’ve been trying to find a way of sorting this with standard commandline tools, bash, awk, sort, whatever but can’t find a way apart from using perl or similar.
Any hint?
Input data
header1
3
2
5
1
header2
5
1
3
.....
.....
Output data
header1
1
2
3
5
header2
1
....
Thanks
Assumes sections are separated by blank lines and the header doesn’t necessarily contain the string “header”. Leaves the sections in the original order so the sort is stable. Reads from stdin, displays on stdout.
Or as a one-liner: