Powiel możliwe:
How to sort numeric and literal columns in VimSortuj numerycznie w edytorze VI
muszę uporządkować poniższe linie oparte na identyfikator wątku.
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}
Kiedy wydawać :!sort -n
dostają sortowane tak:
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}
Ale muszę im być klasyfikowane tak:
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}
W twoim przypadku zrobione jako ':%! sort -n -k 3' –
@MichaelBerkowski: Dzięki temu działa idealnie. Podaj tę odpowiedź jako odpowiedź, aby ją zaakceptować. Rozumiem opcje "n" i "3". Ale dlaczego potrzebuję dodatkowego '-k'. Czy 'n' nie jest wystarczający do sortowania numerycznego – arunmoezhi
' -k 3' wyraźnie sortuje na trzecim polu. – sebnukem