From 945af4bc70bf3d06040453dc38870281e763e041 Mon Sep 17 00:00:00 2001 From: Michael Hall Date: Tue, 25 Jun 2024 04:30:39 +1000 Subject: [PATCH] sort: add multiple columns example (#13094) --- pages/common/sort.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/common/sort.md b/pages/common/sort.md index e67cba248..f4bf1169a 100644 --- a/pages/common/sort.md +++ b/pages/common/sort.md @@ -23,6 +23,10 @@ `sort --field-separator={{:}} --key={{3n}} {{/etc/passwd}}` +- As above, but when items in the 3rd field are equal, sort by the 4th field by numbers with exponents: + +`sort -t {{:}} -k {{3,3n}} -k {{4,4g}} {{/etc/passwd}}` + - Sort a file preserving only unique lines: `sort --unique {{path/to/file}}` @@ -30,7 +34,3 @@ - Sort a file, printing the output to the specified output file (can be used to sort a file in-place): `sort --output={{path/to/file}} {{path/to/file}}` - -- Sort numbers with exponents: - -`sort --general-numeric-sort {{path/to/file}}`