【发布时间】:2012-11-23 00:36:21
【问题描述】:
在以下示例中,需要对 3 个元素进行排序:
- "[aaa]" 和它下面的 4 行(总是 4)形成一个单元。
- "[kkk]" 和它下面的 4 行(总是 4 行)形成一个单元。
- "[zzz]" 和它下面的 4 行(总是 4 行)形成一个单元。
只有遵循这种模式的行组才应该被排序; "[aaa]" 之前和 "[zzz]" 的第 4 行之后的任何内容都必须保持不变。
来自:
This sentence and everything above it should not be sorted.
[zzz]
some
random
text
here
[aaa]
bla
blo
blu
bli
[kkk]
1
44
2
88
And neither should this one and everything below it.
到:
This sentence and everything above it should not be sorted.
[aaa]
bla
blo
blu
bli
[kkk]
1
44
2
88
[zzz]
some
random
text
here
And neither should this one and everything below it.
【问题讨论】:
-
多么可怕的例子......为什么所有部分的值都相同?注意:我会使用
awk。 -
编辑:现在应该更容易理解了。
-
是的,之前和之后的数据插图是要走的路。祝你好运。