bash输出行按降序排序

时间:2018-03-12 15:14:32

标签: bash

数据如下:

Web Application Attack: 1361698
Network Trojan was detected: 3272
Potentially Bad Traffic: 0
Misc activity: 0
Detection of Network Scan: 0

我正在寻找一个按行号排序的命令,我尝试过的任何东西都没有用。

1 个答案:

答案 0 :(得分:4)

试试这个:

sort -n -r -t':' -k2,2 <data_file>

说明:

-n: Numeric sort
-r: Reverse (descending)
-t: Changes field separator to ':' character
-k: Sort key starts on field 2 and ends on field 2