I have this file:
100: pattern1
++++++++++++++++++++
1:pattern2
9:pattern2
+++++++++++++++++++
79: pattern1
61: pattern1
+++++++++++++++++++
and I want to sort it as follows:
++++++++++++++++++++
1:pattern2
9:pattern2
+++++++++++++++++++
61:pattern1
79:pattern1
100:pattern1
+++++++++++++++++++
Is it possible to use only the Linux sort command?
If I had:
4:pat1
3:pat2
2:pat2
1:pat1
O / p should be:
1:pat1
++++++++++++
2:pat2
3:pat2
++++++++++++
4:pat1
So, you want to sort the first group, but the "group" according to the template of the second group. Note that the thing after: is a regular expression pattern, not a literal.
source
share