【发布时间】:2012-12-14 02:50:10
【问题描述】:
我必须根据线程 ID 对以下行进行排序。
Internal thread 0 bound to OS proc set {1}
Internal thread 1 bound to OS proc set {5}
Internal thread 2 bound to OS proc set {9}
Internal thread 10 bound to OS proc set {41}
Internal thread 9 bound to OS proc set {37}
当我发出:!sort -n 时,它们的排序如下:
Internal thread 0 bound to OS proc set {1}
Internal thread 1 bound to OS proc set {5}
Internal thread 10 bound to OS proc set {41}
Internal thread 2 bound to OS proc set {9}
Internal thread 9 bound to OS proc set {37}
但我需要像这样对它们进行排序:
Internal thread 0 bound to OS proc set {1}
Internal thread 1 bound to OS proc set {5}
Internal thread 2 bound to OS proc set {9}
Internal thread 9 bound to OS proc set {37}
Internal thread 10 bound to OS proc set {41}
【问题讨论】:
-
在你的情况下,作为
:%!sort -n -k 3完成 -
@MichaelBerkowski:感谢它完美运行。请提供此作为答案,以便我接受。我了解
n和3选项。但是为什么我需要一个额外的-k。n是否不足以进行数字排序 -
-k 3明确排序第三个字段。
标签: vim text-editor vi