使用 coreutils 排序,您可以这样做(使用一般数字排序顺序):
sort -k3,3g file
输出:
5.7015 40828240 +152 -> explode(string(1), string(21)) /f.inc:467
5.7027 40835000 +152 -> explode(string(1), string(21)) /f.inc:467
5.7020 40834088 +160 -> explode(string(1), string(21)) /f.inc:467
5.7020 40834040 +192 -> explode(string(1), string(21)) /f.inc:467
5.7023 40834392 +192 -> explode(string(1), string(21)) /f.inc:467
编辑 - 适应新的输入
如果输入如OP 所列,我认为需要进行一些预过滤来加入相关行,类似于sed 'N; /\n *>=>/ s// >=>/; P; D'
. 综合起来:
< 1.xt.txt sed 'N; /\n *>=>/ s// >=>/; P; D' | sort -k3,3g
输出:
TRACE START [2013-01-15 13:17:48]
0.0149 2268328 +0 -> realpath(string(36)) /htdocs/lib/functions.inc:2 >=> '/htdocs/lib'
0.0016 942488 +80 -> header(string(38)) /htdocs/scripts/univexport.php:8 >=> NULL
0.0016 941816 +160 -> error_reporting(long) /htdocs/scripts/univexport.php:4 >=> 22527
0.0016 942008 +192 -> set_time_limit(long) /htdocs/scripts/univexport.php:5 >=> TRUE
0.0148 2268328 +264 -> dirname(string(50)) /htdocs/lib/functions.inc:2 >=> '/htdocs/lib'
0.0016 942408 +400 -> ini_set(string(12), string(5)) /htdocs/scripts/univexport.php:6 >=> '-1'
0.0188 2651104 +382776 -> require_once(1/htdocs/lib/functions_common.inc) /htdocs/lib/functions.inc:2
0.0014 941656 +941656 -> {main}() /htdocs/scripts/univexport.php:0
0.0147 2268064 +1325576 -> include_once(/htdocs/lib/functions.inc) /htdocs/scripts/univexport.php:9
标题被排序到顶部,因为它被认为是一个字符串,一般的数字顺序决定了这样的顺序(来自 GNU 排序手册):